summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@intel.com>2017-08-21 21:00:45 +0000
committerCraig Topper <craig.topper@intel.com>2017-08-21 21:00:45 +0000
commit775ffcc8f5a1321d7e0a41fc6af54c1970b1da0b (patch)
treeff41700a83ac6481d98acc4ff4ac8d33d1d7f30e /llvm/lib/Transforms
parent3d48bb5fc2eb6316fa16a3f48cdf2c8df3ed217d (diff)
downloadbcm5719-llvm-775ffcc8f5a1321d7e0a41fc6af54c1970b1da0b.tar.gz
bcm5719-llvm-775ffcc8f5a1321d7e0a41fc6af54c1970b1da0b.zip
[InstCombine] Move the checks for pointer types in getMaskedTypeForICmpPair earlier in the function
I don't think there's any reason to have them scattered about and on all 4 operands. We already have an early check that both compares must be the same type. And within a given compare the LHS and RHS must have the same type. Beyond that I don't think there's anyway this function returns anything valid for pointer types. So let's just return early and be done with it. Differential Revision: https://reviews.llvm.org/D36561 llvm-svn: 311383
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp18
1 files changed, 6 insertions, 12 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
index 8f0254f2171..636c04f9cd5 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
@@ -314,8 +314,8 @@ static unsigned getMaskedTypeForICmpPair(Value *&A, Value *&B, Value *&C,
ICmpInst::Predicate &PredR) {
if (LHS->getOperand(0)->getType() != RHS->getOperand(0)->getType())
return 0;
- // vectors are not (yet?) supported
- if (LHS->getOperand(0)->getType()->isVectorTy())
+ // vectors are not (yet?) supported. Don't support pointers either.
+ if (!LHS->getOperand(0)->getType()->isIntegerTy())
return 0;
// Here comes the tricky part:
@@ -332,20 +332,14 @@ static unsigned getMaskedTypeForICmpPair(Value *&A, Value *&B, Value *&C,
L21 = L22 = L1 = nullptr;
} else {
// Look for ANDs in the LHS icmp.
- if (!L1->getType()->isIntegerTy()) {
- // You can icmp pointers, for example. They really aren't masks.
- L11 = L12 = nullptr;
- } else if (!match(L1, m_And(m_Value(L11), m_Value(L12)))) {
+ if (!match(L1, m_And(m_Value(L11), m_Value(L12)))) {
// Any icmp can be viewed as being trivially masked; if it allows us to
// remove one, it's worth it.
L11 = L1;
L12 = Constant::getAllOnesValue(L1->getType());
}
- if (!L2->getType()->isIntegerTy()) {
- // You can icmp pointers, for example. They really aren't masks.
- L21 = L22 = nullptr;
- } else if (!match(L2, m_And(m_Value(L21), m_Value(L22)))) {
+ if (!match(L2, m_And(m_Value(L21), m_Value(L22)))) {
L21 = L2;
L22 = Constant::getAllOnesValue(L2->getType());
}
@@ -372,7 +366,7 @@ static unsigned getMaskedTypeForICmpPair(Value *&A, Value *&B, Value *&C,
E = R2;
R1 = nullptr;
Ok = true;
- } else if (R1->getType()->isIntegerTy()) {
+ } else {
if (!match(R1, m_And(m_Value(R11), m_Value(R12)))) {
// As before, model no mask as a trivial mask if it'll let us do an
// optimization.
@@ -398,7 +392,7 @@ static unsigned getMaskedTypeForICmpPair(Value *&A, Value *&B, Value *&C,
return 0;
// Look for ANDs on the right side of the RHS icmp.
- if (!Ok && R2->getType()->isIntegerTy()) {
+ if (!Ok) {
if (!match(R2, m_And(m_Value(R11), m_Value(R12)))) {
R11 = R2;
R12 = Constant::getAllOnesValue(R2->getType());
OpenPOWER on IntegriCloud