[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)
commitf57ae33381f27445d2b174bfae2cd94d49852398
treeffef4d4607f2d887aba8e6756531a810cd14468e
parent513c3e474d9e9ade4c5e232fdfd4bb962c26cab5
[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

llvm-svn: 298845
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/test/Transforms/InstCombine/phi-select-constexpr.ll