summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-06-17 23:17:05 +0000
committerDan Gohman <gohman@apple.com>2009-06-17 23:17:05 +0000
commit7f836c7c611c6fe26ce5c27657e6736296c1afad (patch)
treea869d03d27440784277e74c39e295317c29a4112 /llvm/lib/Transforms
parent7bcce49e049411a8f793fcf6fe57639fdbce654a (diff)
downloadbcm5719-llvm-7f836c7c611c6fe26ce5c27657e6736296c1afad.tar.gz
bcm5719-llvm-7f836c7c611c6fe26ce5c27657e6736296c1afad.zip
Instcombine zext(trunc(x) & mask) to x&mask, even if the trunc has
multiple users. llvm-svn: 73656
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/InstructionCombining.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
index 170b47694af..bf287f2c680 100644
--- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -8564,6 +8564,20 @@ Instruction *InstCombiner::visitZExt(ZExtInst &CI) {
}
}
+ // zext(trunc(t) & C) -> (t & C) if C is a mask.
+ if (SrcI && SrcI->getOpcode() == Instruction::And && SrcI->hasOneUse())
+ if (ConstantInt *C = dyn_cast<ConstantInt>(SrcI->getOperand(1)))
+ if (TruncInst *TI = dyn_cast<TruncInst>(SrcI->getOperand(0))) {
+ Value *TI0 = TI->getOperand(0);
+ if (TI0->getType() == CI.getType()) {
+ unsigned TO = C->getValue().countTrailingOnes();
+ if (APIntOps::isMask(TO, C->getValue()))
+ return
+ BinaryOperator::Create(Instruction::And, TI0,
+ ConstantExpr::getZExt(C, CI.getType()));
+ }
+ }
+
return 0;
}
OpenPOWER on IntegriCloud