[LV] Fix recording of BranchTakenCount for FoldTail
authorAyal Zaks <ayal.zaks@intel.com>
Sat, 25 Apr 2020 00:44:38 +0000 (03:44 +0300)
committerAyal Zaks <ayal.zaks@intel.com>
Sun, 26 Apr 2020 17:13:10 +0000 (20:13 +0300)
commita3c964a278b434a587f447dac144bb7d92227dab
treed65beee4793c4863884d63dc78e6ee0da2c2015b
parent2f3e86b31818222a0ab87c4114215e86b89c9dfc
[LV] Fix recording of BranchTakenCount for FoldTail

When folding tail, branch taken count is computed during initial VPlan execution
and recorded to be used by the compare computing the loop's mask. This recording
should directly set the State, instead of reusing Value2VPValue mapping which
serves original Values present prior to vectorization.
The branch taken count may be a constant Value, which may be used elsewhere in
the loop; trying to employ Value2VPValue for both leads to the issue reported in
https://reviews.llvm.org/D76992#inline-721028

Differential Revision: https://reviews.llvm.org/D78847
llvm/lib/Transforms/Vectorize/VPlan.cpp
llvm/lib/Transforms/Vectorize/VPlan.h
llvm/test/Transforms/LoopVectorize/X86/x86-interleaved-accesses-masked-group.ll
llvm/test/Transforms/LoopVectorize/tail-folding-counting-down.ll