This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: RFC: Combine of compare & and oddity
- From: Segher Boessenkool <segher at kernel dot crashing dot org>
- To: Jeff Law <law at redhat dot com>
- Cc: Wilco Dijkstra <wdijkstr at arm dot com>, "'GCC Patches'" <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 2 Sep 2015 16:00:15 -0500
- Subject: Re: RFC: Combine of compare & and oddity
- Authentication-results: sourceware.org; auth=none
- References: <000e01d0e5a2$1e2f66b0$5a8e3410$ at com> <55E7553E dot 8050905 at redhat dot com>
On Wed, Sep 02, 2015 at 01:59:58PM -0600, Jeff Law wrote:
> >(set (reg:CC 66 cc)
> > (compare:CC (and:DI (lshiftrt:DI (subreg:DI (reg/v:SI 76 [ xD.2641 ])
> > 0)
> > (const_int 1 [0x1]))
> > (const_int 1 [0x1]))
> > (const_int 0 [0])))
> Yea, this is an alternative form. I don't offhand remember how/why
> this form appears, but it certainly does. I don't think any ports
> handle this form (but I certainly have done any checks), but I believe
> combine creates it primarily for internal purposes.
Combine replaces zero_ext* with equivalent shift/and patterns and tries
again, if things don't match. Targets with more generic masking insns
do not want to describe the very many cases that can be described with
zero_ext* separately.
rs6000 handles this exact pattern, btw. And I'll be very happy if we can
just drop it :-)
> >I don't understand how ((x >> 1) & 1) != 0 could be a useful expansion (it
> >even uses shifts by 0 at
> >times which are unlikely to ever match anything). Why does combine not try
> >to match the obvious (x &
> >C) != 0 case? Single-bit and mask tests are very common, so this blocks
> >efficient code generation on
> >many targets.
> From md.texi:
>
> cindex @code{zero_extract}, canonicalization of
> @cindex @code{sign_extract}, canonicalization of
> @item
> 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.
Oh it's even documented, thanks. I do still think we should think of
changing this.
Segher