This is the mail archive of the gcc-patches@gcc.gnu.org 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][combine][RFC][2/2] PR rtl-optimization/68796: Perfer zero_extract comparison against zero rather than unsupported shorter modes


On 12/17/2015 10:04 AM, Kyrill Tkachov wrote:

In this case, I'm expecting a QImode compare with zero to map down to
the aarch64 TST reg, #255 instruction which
definitely zeroes out any bits outside of QImode (as it is a bitwise AND
with a bitmask),
so zero_extract is the more correct expression here, no?
It's more about the semantics of the code and how it interacts with RTL generation, optimization and analysis than it is with the final assembly generated by the backend that drives SUBREG vs zero_extract.

The backend assembly code generator is free to implement stricter semantics (such as defining all the bits for a paradoxical subreg), but the rest of the compiler can not depend on those stricter semantics.

The easiest way to think about the subreg case here is that it's used when we've got a narrow object that we want to view in a wider mode, but we don't actually care about the upper bits. The widening is merely to make the mode match another operand.


zero_extract is still the canonical form. subreg is a specialized form for cases where the upper bits are "don't care" values. This should probably be documented as the current state of the world.

I think it's an open question whether or not to drop the subreg form and always use zero-extract. I've certainly seen cases where the former is *supposed* to allow better code generation, but in fact actually gets in the way resulting in poorer code generation.

Jeff


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