[LV] Move insertelement sequence after scalar definitions
authorMatthew Simpson <mssimpso@codeaurora.org>
Mon, 29 Aug 2016 20:14:04 +0000 (20:14 +0000)
committerMatthew Simpson <mssimpso@codeaurora.org>
Mon, 29 Aug 2016 20:14:04 +0000 (20:14 +0000)
commitdf19502b16b59fd6ccfda2ee4a3afa99af31682e
tree084d24f4a597b9a8eb14c50daa75a218ab0e0bea
parent54695a339f5d4f336865a564ab539ff1b5743223
[LV] Move insertelement sequence after scalar definitions

After r279649 when getting a vector value from VectorLoopValueMap, we create an
insertelement sequence on-demand if the value has been scalarized instead of
vectorized. We previously inserted this insertelement sequence before the
value's first vector user. However, this insert location is problematic if that
user is the phi node of a first-order recurrence. With this patch, we move the
insertelement sequence after the last scalar instruction we created when
scalarizing the value. Thus, the value's vector definition in the new loop will
immediately follow its scalar definitions. This should fix PR30183.

Reference: https://llvm.org/bugs/show_bug.cgi?id=30183
llvm-svn: 280001
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/test/Transforms/LoopVectorize/AArch64/first-order-recurrence.ll
llvm/test/Transforms/LoopVectorize/X86/scatter_crash.ll