https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101815
Bug ID: 101815 Summary: unsigned + -1u > 3 is not optimzied to unsigned > 4 if unsigned range is known not to include 0 Product: gcc Version: 12.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- Take: int f(unsigned int a) { if (a == 0) return 0; unsigned int t = a; a += 4294967295; return a > 3u; } int g(unsigned int a) { if (a == 0) __builtin_unreachable(); unsigned int t = a; a += -1; return a > 3u; } Both of these should produce: _7 = a_3(D) > 4; # RANGE [0, 1] NONZERO 1 _4 = (intD.6) _7; But only f does. f is able to be optimized in reassoc1.