From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 40997 invoked by alias); 1 Jul 2015 09:41:17 -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 40800 invoked by uid 48); 1 Jul 2015 09:41:13 -0000 From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/66718] New: Non-invariant ADDR_EXPR not vectorized Date: Wed, 01 Jul 2015 09:41: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: 6.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: 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 keywords bug_severity priority component assigned_to reporter cc target_milestone 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: 2015-07/txt/msg00022.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66718 Bug ID: 66718 Summary: Non-invariant ADDR_EXPR not vectorized Product: gcc Version: 6.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: jakub at gcc dot gnu.org CC: mpolacek at gcc dot gnu.org, rguenth at gcc dot gnu.org Target Milestone: --- E.g. on: int *a[1024], b[1024]; struct S { int u, v, w, x; }; struct S c[1024]; void f0 (void) { for (int i = 0; i < 1024; i++) a[i] = &b[0]; } void f1 (void) { for (int i = 0; i < 1024; i++) { int *p = &b[0]; a[i] = p + i; } } void f2 (int *p) { for (int i = 0; i < 1024; i++) a[i] = &p[i]; } void f3 (void) { for (int i = 0; i < 1024; i++) a[i] = &b[i]; } void f4 (void) { int *p = &c[0].v; for (int i = 0; i < 1024; i++) a[i] = &p[4 * i]; } void f5 (void) { for (int i = 0; i < 1024; i++) a[i] = &c[i].v; } with -O3 -mavx2 we vectorize only the loops where the address computation has been lowered (f1, f2, f4) or is address of invariant (f0), but the vectorizer is not able to vectorize ADDR_EXPR of non-invariant. Richard thinks this would be best solved by lowering such ADDR_EXPR assignments, somewhere in between the last objsz pass and pre, maybe even before reassoc so that it can optimize even that.