PATCH: PR rtl-optimization/50696: [x32] Unnecessary lea
Thu Oct 13 18:11:00 GMT 2011
On Thu, Oct 13, 2011 at 19:06, Richard Kenner
>> An and:DI is cheaper than a zero_extend:DI of an and:SI.
> That depends strongly on the constants and whether the machine is 32-bit
> or 64-bit.
Yes, the rtx_costs take care of that.
> But that's irrelevant in this case since the and:SI will be removed (it
> reflects what already been done).
Do you refer to this in make_extraction:
/* See if this can be done without an extraction. We never can if the
width of the field is not the same as that of some integer mode. For
registers, we can only avoid the extraction if the position is at the
low-order bit and this is either not in the destination or we have the
appropriate STRICT_LOW_PART operation available. */
and this call to force_to_mode in particular:
new_rtx = force_to_mode (inner, tmode,
len >= HOST_BITS_PER_WIDE_INT
? ~(unsigned HOST_WIDE_INT) 0
: ((unsigned HOST_WIDE_INT) 1 << len) - 1,
and from there the call to simplify_and_const_int that does this:
if (constop == nonzero)
Then indeed it should work if you call make_extraction more greedily
than what we do now (which is, just if the constant is one less than a
power of two).
The answer to H.J.'s "Why do we do it for MEM then?" is simply
"because no one ever thought about not doing it" (because there are no
other POINTERS_EXTEND_UNSIGNED == 1 machines). In fact it may even be
advantageous to do it in general, even if in_code != MEM. Only
experimentation can tell.
More information about the Gcc-patches