http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50730
Bug #: 50730 Summary: SLP vectorization confused by unrelated DRs Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassig...@gcc.gnu.org ReportedBy: rgue...@gcc.gnu.org CC: i...@gcc.gnu.org The SLP vectorizer is confused by the aggregate store in typedef __complex__ float Value; struct A { Value a[16 / sizeof (Value)]; } __attribute__ ((aligned(16))); A sum(A a, A b) { a.a[0]+=b.a[0]; a.a[1]+=b.a[1]; return a; } when built with -O3 -fno-tree-sra: <bb 2>: D.2130_11 = REALPART_EXPR <a.a[0]>; D.2131_12 = IMAGPART_EXPR <a.a[0]>; D.2132_13 = REALPART_EXPR <b.a[0]>; D.2133_14 = IMAGPART_EXPR <b.a[0]>; D.2134_15 = D.2130_11 + D.2132_13; D.2135_16 = D.2131_12 + D.2133_14; REALPART_EXPR <a.a[0]> = D.2134_15; IMAGPART_EXPR <a.a[0]> = D.2135_16; D.2136_17 = REALPART_EXPR <a.a[1]>; D.2137_18 = IMAGPART_EXPR <a.a[1]>; D.2138_19 = REALPART_EXPR <b.a[1]>; D.2139_20 = IMAGPART_EXPR <b.a[1]>; D.2140_21 = D.2136_17 + D.2138_19; D.2141_22 = D.2137_18 + D.2139_20; REALPART_EXPR <a.a[1]> = D.2140_21; IMAGPART_EXPR <a.a[1]> = D.2141_22; D.2119 = a; return D.2119; but I don't see why SLP couldn't simply stop analyzing the BB when it encounters a DR that it cannot build or handle. The previous instructions can be still vectorized. If you put an unrelated volatile store at the end of any sequence in a bb-slp testcase this reproduces as well. The above testcase will probably fail due to unsupported strided stores.