This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Teach VRP about __builtin_{ffs,parity,popcount,clz,ctz,clrsb}{,l,ll,imax} (PR target/29776)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Richard Earnshaw <rearnsha at arm dot com>
- Cc: Richard Biener <rguenther at suse dot de>, "Joseph S. Myers" <joseph at codesourcery dot com>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 9 Jul 2013 11:35:23 +0200
- Subject: Re: [PATCH] Teach VRP about __builtin_{ffs,parity,popcount,clz,ctz,clrsb}{,l,ll,imax} (PR target/29776)
- References: <20130705150126 dot GW2336 at tucnak dot redhat dot com> <51DBD5D2 dot 1050406 at arm dot com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Tue, Jul 09, 2013 at 10:20:18AM +0100, Richard Earnshaw wrote:
> On ARM, CLZ has a defined result at zero (32). Furthermore, the
> ACLE specification defines (in the header arm_acle.h) __clz(n) as
> an intrinsic aimed at the CLZ instruction; __clz() has a defined
> result at 0. We want to use __builtin_clz as the implementation for
> __clz rather than inventing another one; but that would require the
> compiler to handle zero correctly.
The patch that has been committed is the conservative one, so it
handles any __builtin_clz{,l,ll,imax} (0) returning the mode bitsize
(because that is pretty much the only value used for 0 by targets if
they specify it). __builtin_ctz{,l,ll,imax} (0) is a different matter,
because the value at 0 varries a lot (-1, mode bitsize, undefined)
for the cases where there is optab, and for the case where __builtin_ctz
needs to be implemented say using clz, or in wider mode, or through library
routines you really can't expect anything meaningful.
So, for CTZ you get the target defined value for 0 if there is one only
if you have a ctz optab for that mode and CTZ_DEFINED_VALUE_AT_ZERO,
otherwise the patch treats it as undefined.
Jakub
- References:
- [PATCH] Teach VRP about __builtin_{ffs,parity,popcount,clz,ctz,clrsb}{,l,ll,imax} (PR target/29776)
- Re: [PATCH] Teach VRP about __builtin_{ffs,parity,popcount,clz,ctz,clrsb}{,l,ll,imax} (PR target/29776)