summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp11
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp18
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp11
3 files changed, 28 insertions, 12 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
index 330db9eb91f..aa31e0d850d 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
@@ -1126,7 +1126,9 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) {
SQ.getWithInstruction(&I)))
return replaceInstUsesWith(I, V);
- bool Changed = SimplifyAssociativeOrCommutative(I);
+ if (SimplifyAssociativeOrCommutative(I))
+ return &I;
+
if (Instruction *X = foldShuffledBinop(I))
return X;
@@ -1367,6 +1369,7 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) {
// TODO(jingyue): Consider willNotOverflowSignedAdd and
// willNotOverflowUnsignedAdd to reduce the number of invocations of
// computeKnownBits.
+ bool Changed = false;
if (!I.hasNoSignedWrap() && willNotOverflowSignedAdd(LHS, RHS, I)) {
Changed = true;
I.setHasNoSignedWrap(true);
@@ -1388,7 +1391,9 @@ Instruction *InstCombiner::visitFAdd(BinaryOperator &I) {
SQ.getWithInstruction(&I)))
return replaceInstUsesWith(I, V);
- bool Changed = SimplifyAssociativeOrCommutative(I);
+ if (SimplifyAssociativeOrCommutative(I))
+ return &I;
+
if (Instruction *X = foldShuffledBinop(I))
return X;
@@ -1471,7 +1476,7 @@ Instruction *InstCombiner::visitFAdd(BinaryOperator &I) {
return replaceInstUsesWith(I, V);
}
- return Changed ? &I : nullptr;
+ return nullptr;
}
/// Optimize pointer differences into the same array into a size. Consider:
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
index 6c78b9c36c1..d1922ccd81d 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
@@ -1405,7 +1405,9 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) {
SQ.getWithInstruction(&I)))
return replaceInstUsesWith(I, V);
- bool Changed = SimplifyAssociativeOrCommutative(I);
+ if (SimplifyAssociativeOrCommutative(I))
+ return &I;
+
if (Instruction *X = foldShuffledBinop(I))
return X;
@@ -1648,7 +1650,7 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) {
A->getType()->isIntOrIntVectorTy(1))
return SelectInst::Create(A, Op0, Constant::getNullValue(I.getType()));
- return Changed ? &I : nullptr;
+ return nullptr;
}
/// Given an OR instruction, check to see if this is a bswap idiom. If so,
@@ -2020,7 +2022,9 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) {
SQ.getWithInstruction(&I)))
return replaceInstUsesWith(I, V);
- bool Changed = SimplifyAssociativeOrCommutative(I);
+ if (SimplifyAssociativeOrCommutative(I))
+ return &I;
+
if (Instruction *X = foldShuffledBinop(I))
return X;
@@ -2287,7 +2291,7 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) {
}
}
- return Changed ? &I : nullptr;
+ return nullptr;
}
/// A ^ B can be specified using other logic ops in a variety of patterns. We
@@ -2474,7 +2478,9 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) {
SQ.getWithInstruction(&I)))
return replaceInstUsesWith(I, V);
- bool Changed = SimplifyAssociativeOrCommutative(I);
+ if (SimplifyAssociativeOrCommutative(I))
+ return &I;
+
if (Instruction *X = foldShuffledBinop(I))
return X;
@@ -2785,5 +2791,5 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) {
}
}
- return Changed ? &I : nullptr;
+ return nullptr;
}
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
index 65046f26259..a539f870aa2 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
@@ -130,7 +130,9 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) {
SQ.getWithInstruction(&I)))
return replaceInstUsesWith(I, V);
- bool Changed = SimplifyAssociativeOrCommutative(I);
+ if (SimplifyAssociativeOrCommutative(I))
+ return &I;
+
if (Instruction *X = foldShuffledBinop(I))
return X;
@@ -393,6 +395,7 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) {
}
}
+ bool Changed = false;
if (!I.hasNoSignedWrap() && willNotOverflowSignedMul(Op0, Op1, I)) {
Changed = true;
I.setHasNoSignedWrap(true);
@@ -412,7 +415,9 @@ Instruction *InstCombiner::visitFMul(BinaryOperator &I) {
SQ.getWithInstruction(&I)))
return replaceInstUsesWith(I, V);
- bool Changed = SimplifyAssociativeOrCommutative(I);
+ if (SimplifyAssociativeOrCommutative(I))
+ return &I;
+
if (Instruction *X = foldShuffledBinop(I))
return X;
@@ -542,7 +547,7 @@ Instruction *InstCombiner::visitFMul(BinaryOperator &I) {
}
}
- return Changed ? &I : nullptr;
+ return nullptr;
}
/// Fold a divide or remainder with a select instruction divisor when one of the
OpenPOWER on IntegriCloud