]> granicus.if.org Git - llvm/commit
[InstCombine] Avoid incorrect folding of select into phi nodes when incoming element...
authorAnna Thomas <anna@azul.com>
Mon, 27 Mar 2017 13:52:51 +0000 (13:52 +0000)
committerAnna Thomas <anna@azul.com>
Mon, 27 Mar 2017 13:52:51 +0000 (13:52 +0000)
commite8b81e06e1bef6dcaba7c056f24e79022ccf3798
tree57ed79d9aa73c96fee233622cd445f53c9449170
parentdf544d6b0bcb3c5cbfb1df39cee14aa59d8955ba
[InstCombine] Avoid incorrect folding of select into phi nodes when incoming element is a vector type

Summary:
We are incorrectly folding selects into phi nodes when the incoming value of a phi
node is a constant vector. This optimization is done in `FoldOpIntoPhi` when the
select condition is a phi node with constant incoming values.
Without the fix, we are miscompiling (i.e. incorrectly folding the
select into the phi node) when the vector contains non-zero
elements.
This patch fixes the miscompile and we will correctly fold based on the
select vector operand (see added test cases).

Reviewers: majnemer, sanjoy, spatel

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298845 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/InstCombine/InstructionCombining.cpp
test/Transforms/InstCombine/phi-select-constexpr.ll