From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21255 invoked by alias); 7 Sep 2011 12:02:30 -0000 Received: (qmail 21245 invoked by uid 22791); 7 Sep 2011 12:02:29 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 07 Sep 2011 12:02:11 +0000 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/50319] New: if-conversion produces unvectorizable conditions Date: Wed, 07 Sep 2011 12:13:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-09/txt/msg00493.txt.bz2 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: unassigned@gcc.gnu.org ReportedBy: rguenth@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: : : # i_30 = PHI # ivtmp.7_1 = PHI D.2735_6 = s1[i_30]; D.2736_7 = s2[i_30]; if (D.2735_6 u<= D.2736_7) goto ; else goto ; : : # 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 ; else goto ; : goto ; after if-conversion: : # i_30 = PHI # ivtmp.7_1 = PHI 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 ; else goto ; 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.