http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50319
Bug #: 50319 Summary: if-conversion produces unvectorizable conditions Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassig...@gcc.gnu.org ReportedBy: rgue...@gcc.gnu.org For double s1[4], s2[4], s3[64]; void foo (void) { int i; for (i = 0; i < 4; i++) s3[0 * 4 + i] = __builtin_isgreater (s1[i], s2[i]) ? -1.0 : 0.0; for (i = 0; i < 4; i++) s3[1 * 4 + i] = (!__builtin_isgreater (s1[i], s2[i])) ? -1.0 : 0.0; } if-conversion generates a) lots of garbage statements, b) it fails to avoid inversions which causes the code to be non-vectorizable for the first loop. Before if-conversion: <bb 2>: <bb 3>: # i_30 = PHI <i_12(6), 0(2)> # ivtmp.7_1 = PHI <ivtmp.7_28(6), 4(2)> D.2735_6 = s1[i_30]; D.2736_7 = s2[i_30]; if (D.2735_6 u<= D.2736_7) goto <bb 5>; else goto <bb 4>; <bb 4>: <bb 5>: # iftmp.0_3 = PHI <-1.0e+0(4), 0.0(3)> s3[i_30] = iftmp.0_3; i_12 = i_30 + 1; ivtmp.7_28 = ivtmp.7_1 - 1; if (ivtmp.7_28 != 0) goto <bb 6>; else goto <bb 7>; <bb 6>: goto <bb 3>; after if-conversion: <bb 3>: # i_30 = PHI <i_12(4), 0(2)> # ivtmp.7_1 = PHI <ivtmp.7_28(4), 4(2)> D.2735_6 = s1[i_30]; D.2736_7 = s2[i_30]; D.2760_34 = D.2735_6 u<= D.2736_7; D.2761_35 = ~D.2760_34; iftmp.0_3 = D.2761_35 ? -1.0e+0 : 0.0; s3[i_30] = iftmp.0_3; i_12 = i_30 + 1; ivtmp.7_28 = ivtmp.7_1 - 1; D.2762_36 = D.2735_6 u<= D.2736_7; D.2763_37 = D.2762_36 | D.2761_35; if (ivtmp.7_28 != 0) goto <bb 4>; else goto <bb 5>; the statements computing D.2762_36 and D.2763_37 are dead. The statement computing D.2761_35 can be avoided by swapping the arms of the generated cond-expr. if-conversion tries to do this but fails for numerous reasons in find_phi_replacement_condition.