Re: [PATCH 3/7] reorg code for shift-shift simplification

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Aug 08, 2018 at 04:03:32AM +0100, Ramsay Jones wrote:
> 
> 
> On 07/08/18 14:03, Luc Van Oostenryck wrote:
> > No functional changes, just moving the core around
> 
> s/core/code/
> 
> > in preparation for shift-shift simplification.
> > 
> > Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
> > ---
> >  simplify.c | 15 ++++++++++-----
> >  1 file changed, 10 insertions(+), 5 deletions(-)
> > 
> > diff --git a/simplify.c b/simplify.c
> > index 9e4a496fd..911ab11a9 100644
> > --- a/simplify.c
> > +++ b/simplify.c
> > @@ -627,14 +627,19 @@ static int simplify_shift(struct instruction *insn, pseudo_t pseudo, long long v
> >  		break;
> >  	case OP_LSR:
> >  		size = operand_size(insn, pseudo);
> > -		/* fall through */
> > +		if (value >= size)
> > +			goto zero;
> > +		switch(DEF_OPCODE(def, pseudo)) {
> > +		case OP_LSR:
> > +			goto case_shift_shift;
> > +		}
> > +		break;
> >  	case OP_SHL:
> >  		if (value >= size)
> >  			goto zero;
> > -		if (pseudo->type != PSEUDO_REG)
> > -			break;
> > -		def = pseudo->def;
> > -		if (def->opcode == insn->opcode) {
> > +		switch(DEF_OPCODE(def, pseudo)) {
> > +		case OP_SHL:
> > +		case_shift_shift:		// also for LSR - lSR
> >  			if (def == insn)	// cyclic DAG!
> >  				break;
> >  			src2 = def->src2;
> > 
> 
> Hmm, OK, it took me quite some time to convince myself that
> there were, in fact, no functional changes. I could not do
> that with the patch text alone - I needed to look up the
> definition of the DEF_OPCODE macro. (Even then, I had to
> stare at the 'pseudo->type != PSEUDO_REG' condition along
> with the following control flow, very very hard! ;-) ).

I know. I could maybe have splitted this patch in two but ...
And this DEF_OPCODE() is a bit disgusting. At several times
I was like: "It's too ugly and needs to go away" and then a
few days later "Grr, I really need something like this".

But I think that once the real shift-shift simplification
is added, the code is quite readable.

-- Luc
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux