https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85186
Bug ID: 85186 Summary: ifcvt can peel iterations affecting code form, and causing vectorization not to happen Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: minor Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: hp at gcc dot gnu.org Target Milestone: --- Created attachment 43833 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43833&action=edit original non-vectorizing case: 1 In a build for x86_64-linux (likely also other targets; this originates elsewhere) at r258635, drop in attached four test-cases into the dg/vect subdir. Observe, when running vect.exp: Running x/gcc/testsuite/gcc.dg/vect/vect.exp ... FAIL: gcc.dg/vect/prXXXXX-1.c scan-tree-dump-times vect "vectorized 1 loops" 1 FAIL: gcc.dg/vect/prXXXXX-1.c -flto -ffat-lto-objects scan-tree-dump-times vect "vectorized 1 loops" 1 I.e. prXXXXX-1.c does not vectorize, while -2..4 does. Partial analysis: On inspection using gdb and dumps, this appears to be because the initialization appears to affect ifcvt (just as a catalyst) causing it to sort-of peel the first iteration of the to-be-vectorized loop, or something to that effect, anyway changing the form of the code such that it is not be recognizable for the loop vectorizer pass that comes next. 1: original (derived from some other gcc test long ago) 2: candidate loop with non-conditional contents: vectorizes. 3: arrays in candidate loop are moved global (i.e. aren't initialized right before the loop): vectorizes. 4: asm("" : : : "memory") inserted after initialization: vectorizes. All-in-all this PR isn't important (with the test-cases being artificial), but when revisiting if-conversion and/or investigates ifcvt vs. loop-vectorization issues, this PR may provide simplified test-cases of an underlying bug.