The vrp47 testcase currently fails on i386 and S/390. The ssa code before vrp looks different for both compared to x86_64 due to a different value returned by BRANCH_COST. (Branches on S/390 are relatively cheap due to a sophisticated branch prediction unit.) Therefore during gimplification fold_truthop (line 5866) uses more branches for function h in vrp47.c than the x86_64 variant. The problem can also be reproduced on x86 when compiling for a cpu with low branch costs defined in i386.c as e.g. -march=i386.
int h(int x, int y) { if ((x >= 0 && x <= 1) && (y >= 0 && y <= 1)) return x && y; else return -1; } Compile the testcase above with: cc1 -m32 -O2 vrp47.c -fdump-tree-vrp -march=i386 The vrp pass is not able to get rid of the comparisons in this case (069t.vrp1 from i386): h (int x, int y) { int D.2021; unsigned int y.1; unsigned int x.0; <bb 2>: x.0_4 = (unsigned int) x_3(D); if (x.0_4 <= 1) goto <bb 3>; else goto <bb 7>; <bb 3>: y.1_6 = (unsigned int) y_5(D); if (y.1_6 <= 1) goto <bb 4>; else goto <bb 7>; <bb 4>: if (x_3(D) != 0) goto <bb 5>; else goto <bb 6>; <bb 5>: if (y_5(D) != 0) goto <bb 7>; else goto <bb 6>; <bb 6>: <bb 7>: # D.2021_1 = PHI <0(6), -1(3), -1(2), 1(5)> return D.2021_1; } -- Summary: VRP fails to get rid of compares Product: gcc Version: 4.5.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: krebbel at gcc dot gnu dot org GCC build triplet: i386-gnu-linux, s390x-ibm-linux GCC host triplet: i386-gnu-linux, s390x-ibm-linux GCC target triplet: i386-gnu-linux, s390x-ibm-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42117