summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2016-06-17 23:36:38 +0000
committerMatt Arsenault <Matthew.Arsenault@amd.com>2016-06-17 23:36:38 +0000
commit8fd597881178c94c5c5c06b768a787e84ff724de (patch)
tree68cae46d929cffab8910afed9c289785fb555386 /llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
parent5b58d0dffb0e8bd891b4f575e423f081f0f2c1cb (diff)
downloadbcm5719-llvm-8fd597881178c94c5c5c06b768a787e84ff724de.tar.gz
bcm5719-llvm-8fd597881178c94c5c5c06b768a787e84ff724de.zip
Revert "Revert "Revert "InstCombine: Reduce trunc (shl x, K) width."""
This seems to be causing an infinite loop / crash in instcombine on some bots. llvm-svn: 273069
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp27
1 files changed, 5 insertions, 22 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
index 75562eca390..dddcd0183b3 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
@@ -566,28 +566,11 @@ Instruction *InstCombiner::visitTrunc(TruncInst &CI) {
// Transform "trunc (and X, cst)" -> "and (trunc X), cst" so long as the dest
// type isn't non-native.
if (Src->hasOneUse() && isa<IntegerType>(SrcTy) &&
- ShouldChangeType(SrcTy, DestTy)) {
-
- // Transform "trunc (and X, cst)" -> "and (trunc X), cst" so long as the dest
- // type isn't non-native.
- if (match(Src, m_And(m_Value(A), m_ConstantInt(Cst)))) {
- Value *NewTrunc = Builder->CreateTrunc(A, DestTy, A->getName() + ".tr");
- return BinaryOperator::CreateAnd(NewTrunc,
- ConstantExpr::getTrunc(Cst, DestTy));
- }
-
- // Transform "trunc (shl X, cst)" -> "shl (trunc X), cst" so long as the
- // dest type isn't non-native and cst < dest size.
- if (match(Src, m_Shl(m_Value(A), m_ConstantInt(Cst)))) {
- const unsigned DestSize = DestTy->getPrimitiveSizeInBits();
- if (Cst->getValue().ult(DestSize)) {
- Value *NewTrunc = Builder->CreateTrunc(A, DestTy, A->getName() + ".tr");
-
- return BinaryOperator::Create(
- Instruction::Shl, NewTrunc,
- ConstantInt::get(DestTy, Cst->getValue().trunc(DestSize)));
- }
- }
+ ShouldChangeType(SrcTy, DestTy) &&
+ match(Src, m_And(m_Value(A), m_ConstantInt(Cst)))) {
+ Value *NewTrunc = Builder->CreateTrunc(A, DestTy, A->getName() + ".tr");
+ return BinaryOperator::CreateAnd(NewTrunc,
+ ConstantExpr::getTrunc(Cst, DestTy));
}
if (Instruction *I = foldVecTruncToExtElt(CI, *this, DL))
OpenPOWER on IntegriCloud