On 12/17/2015 08:58 AM, Bernd Schmidt wrote:
On 12/17/2015 04:36 PM, Kyrill Tkachov wrote:
The documentation on RTL canonical forms in md.texi says:
"Equality comparisons of a group of bits (usually a single bit) with zero
will be written using @code{zero_extract} rather than the equivalent
@code{and} or @code{sign_extract} operations. "
However, this is not always followed in combine. If it's trying to
optimise
a comparison against zero of a bitmask that is the mode mask of some mode
(255 for QImode and 65535 for HImode in the testcases of this patch)
it will instead create a subreg to that shorter mode.
I suspect that this is an oversight in the documentation, and if given
two choices the simpler form is intended to be the canonical one.
It's also the case that sometimes a SUBREG is preferred because it
conveys that certain bits are "don't care". In theory this may allow
things to optimize better.
However, in practice, I'm not sure that's regularly the case because
various passes are weak in trying to exploit the semantics of the SUBREG
and passes are generally pretty strong in their handling of zero_extract
and friends.
IIRC I actually bumped against this in the gcc-5 cycle when fixing some
suboptimal code generation issues. I think it was BZ15184. I'd check
the archives for Dec 2014 and Jan 2015. There may be a mention of this
issue in there from me (I can recall bumping into it, but can't recall
if I ever did mentioned it publicly or if I ever submitted the change to
prefer the zero_extract form over the subreg form.
Jeff