Consider: int foo (void) { return -1; }
int bar (void) { unsigned int a = 0xffffffff; return a; } int baz (void) { int a = -1; unsigned int b = 0xffffffff; return a == (int) b; } Here is what I get: ;; Function foo (foo) foo () { <bb 0>: return -1; } ;; Function bar (bar) bar () { int D.1124; <bb 0>: D.1124 = -000000001; return D.1124; } ;; Function baz (baz) baz () { int b.0; <bb 0>: b.0 = -000000001; return b.0 == -1; } Note that -1 is represented in two different ways in foo and bar. Worse yet, the tree optimizers do not know that they are equal in baz. baz is optimized as expected at RTL level. -- Summary: Inconsistent handling of -1. Product: gcc Version: unknown Status: UNCONFIRMED Keywords: missed-optimization, TREE Severity: enhancement Priority: P2 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: kazu at cs dot umass dot edu CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19788