From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2081 invoked by alias); 31 Dec 2013 22:42:26 -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 Received: (qmail 2057 invoked by uid 48); 31 Dec 2013 22:42:21 -0000 From: "bmei at broadcom dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/59651] [4.9 Regression] Vectorizer failing to spot dependence causes incorrect code generation. Date: Tue, 31 Dec 2013 22:42:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: bmei at broadcom dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.9.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-12/txt/msg02510.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59651 --- Comment #3 from Bingfeng Mei --- I can reproduce on aarch64. Still try to understand why. I constructed a similar test but with positive loop step. extern void abort (void); int a[] = { 6, 0, 0, 0 }; int b; int main () { for (;;) { b = 0; for (; b<3; b += 1) a[b] = a[0] > 1; break; } if (a[2] != 0) abort (); return 0; } Actually GCC behaves similarly during vectorization and does vectorize the loop. The only difference is around loop versioning. pr52943.c : if (1 != 0) goto ; else goto ; bb 11 leads to vectorized version. So scalar version gets optimized out. Above example: : if (0 != 0) goto ; else goto ; So vectorized version goes away and only scalar version remains.