https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107052
Aldy Hernandez <aldyh at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2022-09-27
CC| |amacleod at redhat dot com
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
--- Comment #2 from Aldy Hernandez <aldyh at gcc dot gnu.org> ---
Don't you mean the only values for popcount are 0-2? I mean, there are only
two bits that could be 1 with a mask of 0x300. Or am I missing something?
Either way, your check is for b > 3, and we should be able to fold that away.
There are two problems here. The cast of a_4 to a.0_1 dropped the nonzero
mask. I would've expected that a cast to a number of the same precision would
keep the 0x300 mask, instead we have:
a.0_1 : [irange] unsigned int [0, 768] NONZERO 0x3ff
If we had the 0x300 mask available in cfn_popcount::fold_range(), then we could
fold it. The second problem is that cfn_popcont, does not look at the nonzero
bits at all.
=========== BB 2 ============
Imports: a_3(D)
Exports: a.0_1 a_3(D) a_4 b_5
a.0_1 : a_3(D)(I) a_4
a_4 : a_3(D)(I)
b_5 : a.0_1 a_3(D)(I) a_4
a_3(D) [irange] int VARYING
<bb 2> :
a_4 = a_3(D) & 768;
a.0_1 = (unsigned int) a_4;
b_5 = __builtin_popcount (a.0_1);
if (b_5 > 3)
goto <bb 3>; [INV]
else
goto <bb 4>; [INV]
a.0_1 : [irange] unsigned int [0, 768] NONZERO 0x3ff
a_4 : [irange] int [0, 768] NONZERO 0x300
b_5 : [irange] int [0, 10] NONZERO 0xf
2->3 (T) a.0_1 : [irange] unsigned int [0, 768] NONZERO 0x3ff
2->3 (T) a_4 : [irange] int [0, 768] NONZERO 0x300
2->3 (T) b_5 : [irange] int [4, 10] NONZERO 0xf
2->4 (F) a.0_1 : [irange] unsigned int [0, 768] NONZERO 0x3ff
2->4 (F) a_4 : [irange] int [0, 768] NONZERO 0x300
2->4 (F) b_5 : [irange] int [0, 3] NONZERO 0x3