summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
index 4cdf154764b..529dc9db049 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
@@ -1212,6 +1212,13 @@ bool InstCombiner::shouldOptimizeCast(CastInst *CI) {
isa<CmpInst>(CastSrc) && CI->getDestTy()->isVectorTy())
return false;
+ // Don't optimize the cast if it is a (zext icmp) that can already be
+ // eliminated.
+ if (auto *ZExt = dyn_cast<ZExtInst>(CI))
+ if (auto *ICmp = dyn_cast<ICmpInst>(CastSrc))
+ if (transformZExtICmp(ICmp, *ZExt, false))
+ return false;
+
return true;
}
@@ -1260,8 +1267,7 @@ Instruction *InstCombiner::foldCastedBitwiseLogic(BinaryOperator &I) {
Value *Cast1Src = Cast1->getOperand(0);
// fold logic(cast(A), cast(B)) -> cast(logic(A, B))
- if ((!isa<ICmpInst>(Cast0Src) || !isa<ICmpInst>(Cast1Src)) &&
- shouldOptimizeCast(Cast0) && shouldOptimizeCast(Cast1)) {
+ if (shouldOptimizeCast(Cast0) && shouldOptimizeCast(Cast1)) {
Value *NewOp = Builder->CreateBinOp(LogicOpc, Cast0Src, Cast1Src,
I.getName());
return CastInst::Create(CastOpcode, NewOp, DestTy);
OpenPOWER on IntegriCloud