From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5703 invoked by alias); 20 Jul 2011 17:00:42 -0000 Received: (qmail 5677 invoked by uid 22791); 20 Jul 2011 17:00:40 -0000 X-SWARE-Spam-Status: No, hits=-2.8 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, 20 Jul 2011 17:00:27 +0000 From: "vincenzo.innocente at cern dot ch" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/49795] vectorization of conditional code happens only on local variables X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: vincenzo.innocente at cern dot ch X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Wed, 20 Jul 2011 17:00: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-07/txt/msg01685.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49795 --- Comment #6 from vincenzo Innocente 2011-07-20 16:59:20 UTC --- actually -ftree-loop-if-convert-stores does the "trick" with -Ofast things are not fully consistent though of these four loop I get the following notice how the combination -ftree-loop-if-convert-stores -03 vectorize the first BUT not the second! const int N=1024; float __attribute__ ((aligned(16))) a[N]; float __attribute__ ((aligned(16))) b[N]; float __attribute__ ((aligned(16))) c[N]; float __attribute__ ((aligned(16))) d[N]; void loop1() { for (int i=0; i!=N; ++i) { d[i]=a[i]+b[i]; if (c[i]<0) d[i] = -d[i]; } } void loop2() { for (int i=0; i!=N; ++i) { float tmp = a[i]+b[i]; if (c[i]<0) tmp = -tmp; d[i]=tmp; } } void loop3() { for (int i=0; i!=N; ++i) { d[i] = (c[i]>0) ? a[i]+b[i] : -a[i]-b[i]; } } void loop4() { for (int i=0; i!=N; ++i) { float tmp = a[i]+b[i]; tmp = (c[i]>0) ? tmp : -tmp; d[i] = tmp; } } c++ -Wall -O3 -ftree-vectorizer-verbose=2 -c test/testBug.cpp -o bha.o test/testBug.cpp:9: note: vectorized 0 loops in function. test/testBug.cpp:17: note: LOOP VECTORIZED. test/testBug.cpp:16: note: vectorized 1 loops in function. test/testBug.cpp:24: note: vectorized 0 loops in function. test/testBug.cpp:31: note: not vectorized: unsupported data-type bool test/testBug.cpp:30: note: vectorized 0 loops in function. pb-d-128-141-131-10:Octave innocent$ c++ -Wall -O3 -ftree-vectorizer-verbose=2 -c test/testBug.cpp -o bha.o -ftree-loop-if-convert-stores test/testBug.cpp:10: note: LOOP VECTORIZED. test/testBug.cpp:9: note: vectorized 1 loops in function. test/testBug.cpp:16: note: vectorized 0 loops in function. test/testBug.cpp:24: note: vectorized 0 loops in function. test/testBug.cpp:30: note: vectorized 0 loops in function. pb-d-128-141-131-10:Octave innocent$ c++ -Wall -Ofast -ftree-vectorizer-verbose=2 -c test/testBug.cpp -o bha.o -ftree-loop-if-convert-stores test/testBug.cpp:10: note: LOOP VECTORIZED. test/testBug.cpp:9: note: vectorized 1 loops in function. test/testBug.cpp:17: note: LOOP VECTORIZED. test/testBug.cpp:16: note: vectorized 1 loops in function. test/testBug.cpp:25: note: LOOP VECTORIZED. test/testBug.cpp:24: note: vectorized 1 loops in function. test/testBug.cpp:31: note: LOOP VECTORIZED. test/testBug.cpp:30: note: vectorized 1 loops in function.