diff options
author | Craig Topper <craig.topper@intel.com> | 2017-07-06 18:39:47 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@intel.com> | 2017-07-06 18:39:47 +0000 |
commit | 79ab643da842b03da893a0188426450525e6ada5 (patch) | |
tree | 6a1a91dac806eca4ea8b6b95373193626e0d94a6 /llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp | |
parent | eb6d5d19508c5485aafb7f9a30dee819a3b64352 (diff) | |
download | bcm5719-llvm-79ab643da842b03da893a0188426450525e6ada5.tar.gz bcm5719-llvm-79ab643da842b03da893a0188426450525e6ada5.zip |
[Constants] If we already have a ConstantInt*, prefer to use isZero/isOne/isMinusOne instead of isNullValue/isOneValue/isAllOnesValue inherited from Constant. NFCI
Going through the Constant methods requires redetermining that the Constant is a ConstantInt and then calling isZero/isOne/isMinusOne.
llvm-svn: 307292
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp index 5407cf6d6a6..56197113c59 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp @@ -227,8 +227,8 @@ static bool isSelect01(Constant *C1, Constant *C2) { return false; if (!C1I->isZero() && !C2I->isZero()) // One side must be zero. return false; - return C1I->isOne() || C1I->isAllOnesValue() || - C2I->isOne() || C2I->isAllOnesValue(); + return C1I->isOne() || C1I->isMinusOne() || + C2I->isOne() || C2I->isMinusOne(); } /// Try to fold the select into one of the operands to allow further @@ -617,10 +617,10 @@ Instruction *InstCombiner::foldSelectInstWithICmp(SelectInst &SI, if (TrueVal->getType() == Ty) { if (ConstantInt *Cmp = dyn_cast<ConstantInt>(CmpRHS)) { ConstantInt *C1 = nullptr, *C2 = nullptr; - if (Pred == ICmpInst::ICMP_SGT && Cmp->isAllOnesValue()) { + if (Pred == ICmpInst::ICMP_SGT && Cmp->isMinusOne()) { C1 = dyn_cast<ConstantInt>(TrueVal); C2 = dyn_cast<ConstantInt>(FalseVal); - } else if (Pred == ICmpInst::ICMP_SLT && Cmp->isNullValue()) { + } else if (Pred == ICmpInst::ICMP_SLT && Cmp->isZero()) { C1 = dyn_cast<ConstantInt>(FalseVal); C2 = dyn_cast<ConstantInt>(TrueVal); } @@ -629,7 +629,7 @@ Instruction *InstCombiner::foldSelectInstWithICmp(SelectInst &SI, Value *AShr = Builder->CreateAShr(CmpLHS, Ty->getBitWidth()-1); // Check if we can express the operation with a single or. - if (C2->isAllOnesValue()) + if (C2->isMinusOne()) return replaceInstUsesWith(SI, Builder->CreateOr(AShr, C1)); Value *And = Builder->CreateAnd(AShr, C2->getValue()-C1->getValue()); |