[LV] Fix PR34711 - widen instruction ranges when sinking casts
authorAyal Zaks <ayal.zaks@intel.com>
Thu, 5 Oct 2017 12:41:49 +0000 (12:41 +0000)
committerAyal Zaks <ayal.zaks@intel.com>
Thu, 5 Oct 2017 12:41:49 +0000 (12:41 +0000)
commitfc3f7a4f0c94a41796e5b21df4ff775339683ed0
tree16f9296de918eadeb8fbd519dac8ecfddd7eeb0f
parent4cafbb9b5ed7b2ae0930ee3456e26044c77a21cc
[LV] Fix PR34711 - widen instruction ranges when sinking casts

Instead of trying to keep LastWidenRecipe updated after creating each recipe,
have tryToWiden() retrieve the last recipe of the current VPBasicBlock and check
if it's a VPWidenRecipe when attempting to extend its range. This ensures that
such extensions, optimized to maintain the original instruction order, do so
only when the instructions are to maintain their relative order. The latter does
not always hold, e.g., when a cast needs to sink to unravel first order
recurrence (r306884).

Testcase derived from reproducer of PR34711.

Differential Revision: https://reviews.llvm.org/D38339

llvm-svn: 314981
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/test/Transforms/LoopVectorize/first-order-recurrence.ll