https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101186
Bug ID: 101186 Summary: predictable comparison of integer variables not folded Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: dizhao at os dot amperecomputing.com Target Milestone: --- GCC fail to remove dead codes for following cases: #include <stdio.h> void f (unsigned int a, unsigned int b, unsigned int c) // if a,b,c are signed, VRP can remove dead code { if (a == b) { printf ("a"); if (c < a) { printf ("b"); if (c >= b) printf ("Unreachable!"); } } } void g (int a, int b, int x, int y) { int c = y; if (a != 0) c = x; while (b < 1000) // without this loop, jump thread & VRP can remove dead code { if (a != 0) { if (c > x) printf ("Unreachable!"); } else printf ("a\n"); b++; } }