From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8160 invoked by alias); 31 Dec 2013 16:28:40 -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 8141 invoked by uid 48); 31 Dec 2013 16:28:35 -0000 From: "belagod at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/59651] New: Vectorizer failing to spot dependence causes incorrect code generation. Date: Tue, 31 Dec 2013 16:28: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-Version: 4.9.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: belagod 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-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: 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/msg02500.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59651 Bug ID: 59651 Summary: Vectorizer failing to spot dependence causes incorrect code generation. Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: belagod at gcc dot gnu.org Hi, This patch (http://gcc.gnu.org/ml/gcc-patches/2013-12/msg01588.html) seems to uncover a bug in the vectorizer where it fails to spot dependence. When test case gcc.dg/torture/pr52943.c is compiled with -O3, the vectorizer generates: main () { vector(2) int * vectp_a.10; vector(2) int * vectp_a.9; vector(2) int vect_cst_.8; unsigned int tmp.7; int tmp.6; int b_lsm.5; unsigned int patt_1; int patt_3; unsigned int ivtmp_4; int _5; _Bool _6; int _7; unsigned int ivtmp_8; int b.1_9; unsigned int ivtmp_10; int _11; int patt_12; unsigned int patt_15; int b.0_16; int b.0_30; unsigned int ivtmp_31; int b.1_33; unsigned int ivtmp_34; int b.0_37; unsigned int ivtmp_39; unsigned int ivtmp_48; : _5 = a[3]; _6 = _5 > 1; _7 = (int) _6; vect_cst_.8_43 = {_7, _7}; vectp_a.10_44 = &MEM[(void *)&a + 8B]; : # b.0_16 = PHI # ivtmp_4 = PHI # vectp_a.9_45 = PHI # ivtmp_8 = PHI MEM[(int *)vectp_a.9_45] = vect_cst_.8_43; b.1_9 = b.0_16 + -1; ivtmp_10 = ivtmp_4 - 1; vectp_a.9_46 = vectp_a.9_45 + 18446744073709551608; ivtmp_48 = ivtmp_8 + 1; if (ivtmp_48 < 1) goto ; else goto ; : # b.0_30 = PHI # ivtmp_31 = PHI a[b.0_30] = _7; b.1_33 = b.0_30 + -1; ivtmp_34 = ivtmp_31 - 1; if (ivtmp_34 != 0) goto ; else goto ; : goto ; : # b.0_37 = PHI # ivtmp_39 = PHI goto ; : goto ; : b = 0; _11 = a[1]; if (_11 != 0) goto ; else goto ; : abort (); : return 0; } >>From the above test, it seems that _7 is precalculated in BB 2 using _5 = a[3]; _6 = _5 > 1; _7 = (int) _6; vect_cst_.8_43 = {_7, _7}; and stored everywhere without considering the dependence on a[3]. MEM[(int *)vectp_a.9_45] = vect_cst_.8_43; ... # b.0_30 = PHI # ivtmp_31 = PHI a[b.0_30] = _7; b.1_33 = b.0_30 + -1; ivtmp_34 = ivtmp_31 - 1; I observed this while running regressions on aarch64. My config is: .../gcc/configure --target=aarch64-none-elf --prefix=.../install --with-gmp=.../host-tools --with-mpfr=.../host-tools --with-mpc=.../host-tools --with-pkgversion=unknown --disable-shared --disable-nls --disable-threads --disable-tls --enable-checking=yes --enable-languages=c,c++ --with-newlib