https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86707
Andrew Macleod <amacleod at redhat dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |amacleod at redhat dot com --- Comment #2 from Andrew Macleod <amacleod at redhat dot com> --- This should get taken care of when ranger tracks must-be-one bits. _1 = x_7(D) & 1; if (_1 == 0) goto <bb 3>; [INV] else goto <bb 4>; [INV] _1 : unsigned int [0, 1] 2->3 (T) _1 : unsigned int [0, 0] 2->3 (T) x_7(D) : unsigned int [0, 4294967294] 2->4 (F) _1 : unsigned int [1, 1] 2->4 (F) x_7(D) : unsigned int [1, +INF] <..> =========== BB 4 ============ x_7(D) unsigned int [1, +INF] <bb 4> : _2 = x_7(D) & 3; if (_2 == 0) goto <bb 5>; [INV] Ideally, taking edge 2->4 will instead produce something like: x_7(D) unsigned int [1, +INF], bits set 0x0001 This would come from operator_bitwise_and::op1_range() with the LHS being subsituted back from the edge: [1,1] = x_7 & 1 in order for that to be true, the mask will have to be must-be-one and then the calculation of _2 = x_7(D) & 3; would produce a non-zero range when operator_bitwise_and sees the must-be-one bit, and propagates it since that bit is in the mask. so we'd get something like: _2 = [1, 3] bits set 0x0001 which would then allow _2 == 0 to be folded as always false. Planned for next release. PR 83073 also touched on this, but not in as much detail nor with as good an exmaple.