https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96397
Bug ID: 96397 Summary: GCC Fails to exploit ranges from overflow tests Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: law at redhat dot com Target Milestone: --- Compile with -O2. We should be able to eliminate the x > p1 test if we were smart about back propagating equivalences to generate a range from the __builtin_add_overflow. This was derived from a bogus warning in tpm2-pkcs11's testsuite. #include <stddef.h> #include <stdlib.h> extern void frob (void); void foo(size_t p1) { size_t x = p1 - 4; size_t y; if (__builtin_add_overflow (x, 8, &y)) { frob (); } else { if (x > p1) abort (); } }