[RFA] [PATCH][PR tree-optimization/59749] Fix recently introduced ree bug

Jeff Law law@redhat.com
Fri Jan 10 22:53:00 GMT 2014

On 01/10/14 14:52, Jakub Jelinek wrote:
> There is one thing I still worry about, if some target has
> an insn to say sign extend or zero extend a short memory load
> into HARD_REGNO_NREGS () > 1 register, but the other involved
> register has the only one (or fewer) hard registers available to it.
> Consider registers SImode hard registers 0, 1, 2, 3:
>    (set (reg:SI 3) (something:SI))
>    (set (reg:HI 0) (expression:HI))
>    (set (reg:SI 2) (sign_extend:SI (reg:HI 0)))
>    (set (reg:DI 0) (sign_extend:DI (reg:HI 0)))
>    (use (reg:SI 3))
> we transform this into:
>    (set (reg:SI 3) (something:SI))
>    (set (reg:SI 2) (sign_extend:SI (expression:HI)))
>    (set (reg:SI 0) (reg:HI 2))
>    (set (reg:DI 0) (sign_extend:DI (reg:HI 0)))
>    (use (reg:SI 3))
> first (well, the middle is then pending in copy list), and next:
>    (set (reg:SI 3) (something))
>    (set (reg:DI 2) (sign_extend:DI (expression:HI)))
>    (set (reg:DI 0) (reg:DI 2))
>    (use (reg:SI 3))
> but that looks wrong, because the second instruction would now clobber
> (reg:SI 3).  Dunno if we have such an target and thus if it is possible
> to construct a testcase.
Seems like any port where we can do operations on 3 different modes and 
the largest mode requires > 1 hard reg ought to do.  I don't see 
anything inherent in this setup that wouldn't apply to x86 for example.

> So, I'd say the handling of the second extend should notice that
> it is actually extending load into a different register and bail out
> if it would need more hard registers than it needed previously, or
> something similar.
That ought to be a trivial check to add.   Let me add it and see if I 
can find something to trip it.

> The printf prototype isn't needed, and the noreturn attributes
> aren't needed either, as they are builtins, the compiler will
> add those automatically.
The printf prototype came from the original and I forgot to remove it 
when I zapped the printf statement.  As for abort/exit, they're not 
strictly needed, but they shut up the compiler when running things by 
hand during testing/development. They're easy enough to zap.


More information about the Gcc-patches mailing list