summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/InstCombine
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2016-07-03 14:34:39 +0000
committerSanjay Patel <spatel@rotateright.com>2016-07-03 14:34:39 +0000
commitcbaac41856334fbe0d87b8d7afac4a3c07e4e84b (patch)
tree3bfe7a23f648654cef66bc262986bc47e53498ab /llvm/lib/Transforms/InstCombine
parent598bdb6bfef2d316baf7cf2d2f77905f99031a8d (diff)
downloadbcm5719-llvm-cbaac41856334fbe0d87b8d7afac4a3c07e4e84b.tar.gz
bcm5719-llvm-cbaac41856334fbe0d87b8d7afac4a3c07e4e84b.zip
[InstCombine] enable vector select of bools -> logic folds
llvm-svn: 274465
Diffstat (limited to 'llvm/lib/Transforms/InstCombine')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
index da4d7c39025..c8ba0b89b48 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -918,9 +918,11 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) {
SimplifySelectInst(CondVal, TrueVal, FalseVal, DL, TLI, DT, AC))
return replaceInstUsesWith(SI, V);
- if (SI.getType()->isIntegerTy(1)) {
- if (ConstantInt *C = dyn_cast<ConstantInt>(TrueVal)) {
- if (C->getZExtValue()) {
+ if (SI.getType()->getScalarType()->isIntegerTy(1) &&
+ TrueVal->getType() == CondVal->getType()) {
+ const APInt *TrueC;
+ if (match(TrueVal, m_APInt(TrueC))) {
+ if (TrueC->isAllOnesValue()) {
// Change: A = select B, true, C --> A = or B, C
return BinaryOperator::CreateOr(CondVal, FalseVal);
}
@@ -928,8 +930,9 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) {
Value *NotCond = Builder->CreateNot(CondVal, "not." + CondVal->getName());
return BinaryOperator::CreateAnd(NotCond, FalseVal);
}
- if (ConstantInt *C = dyn_cast<ConstantInt>(FalseVal)) {
- if (!C->getZExtValue()) {
+ const APInt *FalseC;
+ if (match(FalseVal, m_APInt(FalseC))) {
+ if (*FalseC == 0) {
// Change: A = select B, C, false --> A = and B, C
return BinaryOperator::CreateAnd(CondVal, TrueVal);
}
OpenPOWER on IntegriCloud