PR 54168: Unnecessary narrowing in tree-ssa-forwprop pass?

Richard Biener richard.guenther@gmail.com
Wed Jan 15 11:00:00 GMT 2014


On Tue, Jan 14, 2014 at 3:49 PM, Richard Earnshaw <rearnsha@arm.com> wrote:
> On 14/01/14 14:32, Jakub Jelinek wrote:
>> Anyway, the above is really a simple case, and I'd call it a
>> backend bug if it isn't able to generate good code out of that.
>
> Exactly which back-end pass are you expecting to simplify
>
> (set (subreg:SI (reg:HI 1) 0) (and:SI (subreg:SI (reg:HI 0) 0)
> (const_int 2)))
>
> (set (reg:SI 2) (zero_extend:SI (reg:HI 1)))

Combine/simplify-rtx should notice that the above simplifies to

(set (reg:SI 2) (and:SI (subreg:SI (reg:HI 0) 0) (const_int 2)))

of course the (set (subreg:SI (reg:HI 1) 0) ... with the use (reg:HI 1)
is an awkward choice for the RTL IL probably making this
difficult for combine to consider?

> (set (reg:SI 3) (ne:SI (reg:SI 2) (const_int 0)))
>
> into
>
> (set (reg:SI 2) (and:SI (subreg:SI (reg:HI 0) 0) (const_int 2)))
>
> (set (reg:SI 3) (ne:SI (reg:SI 2) (const_int 0)))
>
> Combine is about the only pass that does this sort of thing, and that's
> far too often confused by extraneous information that it thinks might be
> helpful, but isn't, or by the fact that the intermediate result is used
> more than once.

The single-use case is of course an issue, but as the two insns are
coming out of expand you can hope that CSE doesn't mess it up
too much before combine.  You can of course try to improve
expansion by combining the zero_extend by using simplify_rtx
directly.

Richard.

> R.
>



More information about the Gcc-patches mailing list