[LV] Don't optimize exit cond during epilogue vectorization.
authorFlorian Hahn <flo@fhahn.com>
Fri, 1 Jul 2022 12:48:38 +0000 (13:48 +0100)
committerFlorian Hahn <flo@fhahn.com>
Fri, 1 Jul 2022 12:48:38 +0000 (13:48 +0100)
commit0dddf04caba55a64f8534518d65311bdac05cf39
tree791aac21533d6a05f350359e086df64b1cf70907
parentb15b1421bc9a11b318b65b489e5fd58dd917db1f
[LV] Don't optimize exit cond during epilogue vectorization.

At the moment, the same VPlan can be used code generation of both the
main vector and epilogue vector loop. This can lead to wrong results, if
the plan is optimized based on the VF of the main vector loop and then
re-used for the epilogue loop.

One example where this is problematic is if the scalar loops need to
execute at least one iteration, e.g. due to interleave groups.

To prevent mis-compiles in the short-term, disable optimizing exit
conditions for VPlans when using epilogue vectorization. The proper fix
is to avoid re-using the same plan for both loops, which will require
support for cloning plans first.

Fixes #56319.
llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/lib/Transforms/Vectorize/VPlan.cpp
llvm/lib/Transforms/Vectorize/VPlan.h
llvm/test/Transforms/LoopVectorize/X86/pr42674.ll
llvm/test/Transforms/LoopVectorize/X86/pr56319-vector-exit-cond-optimization-epilogue-vectorization.ll