diff options
author | Craig Topper <craig.topper@intel.com> | 2017-09-22 18:57:22 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@intel.com> | 2017-09-22 18:57:22 +0000 |
commit | 5b35b687856581bf9c08cafdcd88ff4054f47ec3 (patch) | |
tree | b4b848d8164ab2ea0df3c77560840eff99b41948 | |
parent | 2c9b7d7894f8f54e1afe4d5dc2247c0f6fdd62c1 (diff) | |
download | bcm5719-llvm-5b35b687856581bf9c08cafdcd88ff4054f47ec3.tar.gz bcm5719-llvm-5b35b687856581bf9c08cafdcd88ff4054f47ec3.zip |
[InstCombine] Simplify check for RHS being a splat constant in foldICmpUsingKnownBits by just checking Op1Min==Op1Max rather than going through m_APInt.
llvm-svn: 314017
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp index 0a2d0e58b47..d9ead9893ea 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -4223,12 +4223,11 @@ Instruction *InstCombiner::foldICmpUsingKnownBits(ICmpInst &I) { if (Op1Min == Op0Max) // A <u B -> A != B if max(A) == min(B) return new ICmpInst(ICmpInst::ICMP_NE, Op0, Op1); - const APInt *CmpC; - if (match(Op1, m_APInt(CmpC))) { + if (Op1Min == Op1Max) { // A <u C -> A == C-1 if min(A)+1 == C - if (Op1Max == Op0Min + 1) + if (Op1Min == Op0Min + 1) return new ICmpInst(ICmpInst::ICMP_EQ, Op0, - ConstantInt::get(Op0->getType(), *CmpC - 1)); + ConstantInt::get(Op0->getType(), Op1Min - 1)); } break; } @@ -4240,12 +4239,11 @@ Instruction *InstCombiner::foldICmpUsingKnownBits(ICmpInst &I) { if (Op1Max == Op0Min) // A >u B -> A != B if min(A) == max(B) return new ICmpInst(ICmpInst::ICMP_NE, Op0, Op1); - const APInt *CmpC; - if (match(Op1, m_APInt(CmpC))) { + if (Op1Min == Op1Max) { // A >u C -> A == C+1 if max(a)-1 == C - if (*CmpC == Op0Max - 1) + if (Op1Min == Op0Max - 1) return new ICmpInst(ICmpInst::ICMP_EQ, Op0, - ConstantInt::get(Op1->getType(), *CmpC + 1)); + ConstantInt::get(Op1->getType(), Op1Min + 1)); } break; } |