[LV] Fix recording of BranchTakenCount for FoldTail

Authored by Ayal on Apr 24 2020, 5:44 PM.


[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

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