https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106217
Bug ID: 106217 Summary: [11/12/13 Regression] sinking of loads prevents vectorization Product: gcc Version: 11.3.1 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: tnfchris at gcc dot gnu.org Target Milestone: --- The following example void f(int n, float * __restrict x, float *mass, float max, float &ax) { float lax = 0.0f; for (int i = 0; i < n; ++i) { float f = x[i] * mass[i]; lax += x[i] >= max ? 0 : f * x[i]; } ax += lax; return; } vectorizes with GCC 10 with -Ofast but fails starting with GCC 11. The difference is that in the sink1 pass we now sink the unconditional load of mass[i] into the conditional. Sinking # VUSE <.MEM_14(D)> _7 = *_6; from bb 3 to bb 4 Sinking _6 = mass_18(D) + _2; from bb 3 to bb 4 consequently this causes if-convert to no longer be able to if-convert the loop because the load is now conditional, and we only accept unconditional loads in ifcvt_memrefs_wont_trap. ------------------------- _6 = mass_18(D) + _2; ------------------------- _7 = *_6; tree could trap... perhaps during the sinking we should mark the load as non-trapping? as it was originally unconditional anyway.