summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/InstCombine
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@intel.com>2017-08-28 22:00:27 +0000
committerCraig Topper <craig.topper@intel.com>2017-08-28 22:00:27 +0000
commit516e39cd38cd253b20b1b3b56f5a88a057bbecb1 (patch)
tree90607c53a2305d072d8f8ca4e743c4405625ae96 /llvm/lib/Transforms/InstCombine
parent72aa937ed8cf9a0478bc9908f80ce51e372e8ef4 (diff)
downloadbcm5719-llvm-516e39cd38cd253b20b1b3b56f5a88a057bbecb1.tar.gz
bcm5719-llvm-516e39cd38cd253b20b1b3b56f5a88a057bbecb1.zip
[InstCombine] Teach select01 helper of foldSelectIntoOp to handle vector splats
We were handling some vectors in foldSelectIntoOp, but not if the operand of the bin op was any kind of vector constant. This patch fixes it to treat vector splats the same as scalars. Differential Revision: https://reviews.llvm.org/D37232 llvm-svn: 311940
Diffstat (limited to 'llvm/lib/Transforms/InstCombine')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
index 5712fa4f09c..08aba886575 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -220,16 +220,15 @@ Instruction *InstCombiner::foldSelectOpOp(SelectInst &SI, Instruction *TI,
}
static bool isSelect01(Constant *C1, Constant *C2) {
- ConstantInt *C1I = dyn_cast<ConstantInt>(C1);
- if (!C1I)
+ const APInt *C1I, *C2I;
+ if (!match(C1, m_APInt(C1I)))
return false;
- ConstantInt *C2I = dyn_cast<ConstantInt>(C2);
- if (!C2I)
+ if (!match(C2, m_APInt(C2I)))
return false;
- if (!C1I->isZero() && !C2I->isZero()) // One side must be zero.
+ if (!C1I->isNullValue() && !C2I->isNullValue()) // One side must be zero.
return false;
- return C1I->isOne() || C1I->isMinusOne() ||
- C2I->isOne() || C2I->isMinusOne();
+ return C1I->isOneValue() || C1I->isAllOnesValue() ||
+ C2I->isOneValue() || C2I->isAllOnesValue();
}
/// Try to fold the select into one of the operands to allow further
OpenPOWER on IntegriCloud