This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix up rotate expansion (take 2)

On Wed, Apr 16, 2014 at 10:22:52PM -0400, DJ Delorie wrote:
> > +		{
> > +		  other_amount
> > +		    = simplify_gen_unary (NEG, GET_MODE (op1),
> > +					  op1, GET_MODE (op1));
> > +		  other_amount
> > +		    = simplify_gen_binary (AND, GET_MODE (op1),
> > +					   other_amount,
> > +					   GEN_INT (GET_MODE_PRECISION (mode)
> > +						    - 1));
> > +		}
> >  
> >  	      shifted = force_reg (mode, shifted);
> >  
> causes an ICE in gcc.c-torture/execute/20020226-1.c, which we tried to
> avoid by adding an "addneghi" pattern (which itself has a bug, hence me
> investigating).

I don't see why you would need such an pattern.  Here is what happens
on x86_64 if I forcefully ignore the rotate patterns to excersize this code:

#8  0x0000000000a20bd7 in expand_simple_unop (mode=SImode, code=NEG, op0=0x7ffff19f7600, target=0x7ffff19fc2c0, unsignedp=0)
    at ../../gcc/optabs.c:2511
#9  0x00000000007f180c in force_operand (value=0x7ffff19fd040, target=0x7ffff19fc2c0) at ../../gcc/expr.c:7212
#10 0x00000000007f1457 in force_operand (value=0x7ffff19ddd68, target=0x0) at ../../gcc/expr.c:7154
#11 0x00000000007c8509 in force_reg (mode=SImode, x=0x7ffff19ddd68) at ../../gcc/explow.c:683
#12 0x00000000007dd502 in convert_move (to=0x7ffff19fc2a0, from=0x7ffff19ddd68, unsignedp=1) at ../../gcc/expr.c:607
#13 0x00000000007ddde0 in convert_modes (mode=QImode, oldmode=SImode, x=0x7ffff19ddd68, unsignedp=1) at ../../gcc/expr.c:798
#14 0x0000000000a1ddba in expand_binop_directly (mode=SImode, binoptab=ashl_optab, op0=0x7ffff19f78c0, op1=0x7ffff19ddd68, target=0x0, 
    unsignedp=1, methods=OPTAB_LIB_WIDEN, last=0x7ffff19f4f78) at ../../gcc/optabs.c:1437
#15 0x0000000000a1e18e in expand_binop (mode=SImode, binoptab=ashl_optab, op0=0x7ffff19f78c0, op1=0x7ffff19ddd68, target=0x0, unsignedp=1, 
    methods=OPTAB_LIB_WIDEN) at ../../gcc/optabs.c:1546
#16 0x00000000007d12c9 in expand_shift_1 (code=LSHIFT_EXPR, mode=SImode, shifted=0x7ffff19f78c0, amount=0x7ffff19ddd68, target=0x0, unsignedp=1)
    at ../../gcc/expmed.c:2287
#17 0x00000000007d1209 in expand_shift_1 (code=RROTATE_EXPR, mode=SImode, shifted=0x7ffff19f78c0, amount=0x7ffff19f7600, target=0x0, unsignedp=1)
    at ../../gcc/expmed.c:2275

i.e. the other_amount expression (and (neg ()) (const_int)) is, unless
it is a general_operand (shouldn't be usually the case) is first forced
to register with whatever mode it has (GET_MODE (op1)), and forcing it
into a register forces even the operands of the AND using force_operand,
thus separate NEG and separate AND insn, and then finally is mode converted
(zero extended or truncated) into whatever mode the shift pattern requires.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]