From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4993 invoked by alias); 23 Jun 2011 06:55:36 -0000 Received: (qmail 4982 invoked by uid 22791); 23 Jun 2011 06:55:35 -0000 X-SWARE-Spam-Status: No, hits=-2.7 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; Thu, 23 Jun 2011 06:55:21 +0000 From: "vincenzo.innocente at cern dot ch" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/49513] New: introducing a product inhibit vectorization 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: X-Bugzilla-Severity: major X-Bugzilla-Who: vincenzo.innocente at cern dot ch 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 Date: Thu, 23 Jun 2011 06:55:00 -0000 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-06/txt/msg02053.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49513 Summary: introducing a product inhibit vectorization Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: major Priority: P3 Component: tree-optimization AssignedTo: unassigned@gcc.gnu.org ReportedBy: vincenzo.innocente@cern.ch in the simple example below the first loop vectorize, the second not I'm using gcc version 4.7.0 20110528 (experimental) (GCC) #include float __attribute__ ((aligned(16))) a[1024]; float __attribute__ ((aligned(16))) s[1024]; float __attribute__ ((aligned(16))) c[1024]; inline float bar(float y, float x ){ float xx = fabs(x); float yy = fabs(y); float tmp =0.0f; if (yy>xx) { tmp = yy; yy=xx; xx=tmp; } float t=yy/xx; return t; } void foo1() { for (int i=0; i!=1024; ++i) { float z = i; a[i] = bar(s[i],c[i]); } } void foo2() { for (int i=0; i!=1024; ++i) { float z = i; a[i] = bar(z*s[i],z*c[i]); } } c++ -std=c++0x -Ofast -c vectBug.cc -ftree-vectorizer-verbose=7 vectBug.cc:21: note: vect_model_load_cost: aligned. vectBug.cc:21: note: vect_get_data_access_cost: inside_cost = 1, outside_cost = 0. vectBug.cc:21: note: vect_model_load_cost: aligned. vectBug.cc:21: note: vect_get_data_access_cost: inside_cost = 2, outside_cost = 0. vectBug.cc:21: note: vect_model_store_cost: aligned. vectBug.cc:21: note: vect_get_data_access_cost: inside_cost = 3, outside_cost = 0. vectBug.cc:21: note: vect_model_load_cost: aligned. vectBug.cc:21: note: vect_model_load_cost: inside_cost = 1, outside_cost = 0 . vectBug.cc:21: note: vect_model_load_cost: aligned. vectBug.cc:21: note: vect_model_load_cost: inside_cost = 1, outside_cost = 0 . vectBug.cc:21: note: vect_model_simple_cost: inside_cost = 1, outside_cost = 0 . vectBug.cc:21: note: vect_model_simple_cost: inside_cost = 1, outside_cost = 0 . vectBug.cc:21: note: vect_model_simple_cost: inside_cost = 1, outside_cost = 0 . vectBug.cc:21: note: vect_model_store_cost: aligned. vectBug.cc:21: note: vect_model_store_cost: inside_cost = 1, outside_cost = 0 . vectBug.cc:21: note: Cost model analysis: Vector inside of loop cost: 6 Vector outside of loop cost: 0 Scalar iteration cost: 8 Scalar outside cost: 0 prologue iterations: 0 epilogue iterations: 0 Calculated minimum iters for profitability: 1 vectBug.cc:21: note: Profitability threshold = 3 vectBug.cc:21: note: LOOP VECTORIZED. vectBug.cc:20: note: vectorized 1 loops in function. vectBug.cc:27: note: not vectorized: control flow in loop. vectBug.cc:26: note: vectorized 0 loops in function.