summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorBob Haarman <llvm@inglorion.net>2018-07-18 02:18:28 +0000
committerBob Haarman <llvm@inglorion.net>2018-07-18 02:18:28 +0000
commit4ebe5d59b65222a9b49993be9526588c6b5369f3 (patch)
tree8f4bb6ff5a24b6ffaa97edb061ebe0ff2462bca9 /llvm/lib/Transforms
parent4719c5245572b8cb501ee01015704369a9995c05 (diff)
downloadbcm5719-llvm-4ebe5d59b65222a9b49993be9526588c6b5369f3.tar.gz
bcm5719-llvm-4ebe5d59b65222a9b49993be9526588c6b5369f3.zip
Revert "[InstCombine] Fold 'check for [no] signed truncation' pattern"
This reverts r337190 (and a few follow-up commits), which caused the Chromium build to fail. See https://bugs.llvm.org/show_bug.cgi?id=38204 and https://crbug.com/864832 llvm-svn: 337344
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp69
1 files changed, 0 insertions, 69 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index d67a9793e4f..f91eb9da99e 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -2945,72 +2945,6 @@ static Value *foldICmpWithLowBitMaskedVal(ICmpInst &I,
return Builder.CreateICmp(DstPred, X, M);
}
-/// Some comparisons can be simplified.
-/// In this case, we are looking for comparisons that look like
-/// a check for a lossy signed truncation.
-/// Folds: (MaskedBits is a constant.)
-/// ((%x << MaskedBits) a>> MaskedBits) SrcPred %x
-/// Into:
-/// (add %x, (1 << (KeptBits-1))) DstPred (1 << KeptBits)
-/// Where KeptBits = bitwidth(%x) - MaskedBits
-static Value *
-foldICmpWithTruncSignExtendedVal(ICmpInst &I,
- InstCombiner::BuilderTy &Builder) {
- ICmpInst::Predicate SrcPred;
- Value *X;
- const APInt *C0, *C1; // FIXME: non-splats, potentially with undef.
- // We are ok with 'shl' having multiple uses, but 'ashr' must be one-use.
- if (!match(&I, m_c_ICmp(SrcPred,
- m_OneUse(m_AShr(m_Shl(m_Value(X), m_APInt(C0)),
- m_APInt(C1))),
- m_Deferred(X))))
- return nullptr;
-
- // Potential handling of non-splats: for each element:
- // * if both are undef, replace with constant 0.
- // Because (1<<0) is OK and is 1, and ((1<<0)>>1) is also OK and is 0.
- // * if both are not undef, and are different, bailout.
- // * else, only one is undef, then pick the non-undef one.
-
- // The shift amount must be equal.
- if (*C0 != *C1)
- return nullptr;
- const uint64_t MaskedBits = C0->getZExtValue();
- assert(MaskedBits && "shift of %x by zero should be folded to %x already.");
-
- ICmpInst::Predicate DstPred;
- switch (SrcPred) {
- case ICmpInst::Predicate::ICMP_EQ:
- // ((%x << MaskedBits) a>> MaskedBits) == %x
- // =>
- // (add %x, (1 << (KeptBits-1))) u< (1 << KeptBits)
- DstPred = ICmpInst::Predicate::ICMP_ULT;
- break;
- case ICmpInst::Predicate::ICMP_NE:
- // ((%x << MaskedBits) a>> MaskedBits) != %x
- // =>
- // (add %x, (1 << (KeptBits-1))) u>= (1 << KeptBits)
- DstPred = ICmpInst::Predicate::ICMP_UGE;
- break;
- // FIXME: are more folds possible?
- default:
- return nullptr;
- }
-
- const uint64_t XBitWidth = C0->getBitWidth();
- const uint64_t KeptBits = XBitWidth - MaskedBits;
- const uint64_t ICmpCst = (uint64_t)1 << KeptBits; // (1 << KeptBits)
- const uint64_t AddCst = ICmpCst >> 1; // (1 << (KeptBits-1))
-
- auto *XType = X->getType();
- // (add %x, (1 << (KeptBits-1)))
- Value *T0 = Builder.CreateAdd(X, ConstantInt::get(XType, AddCst));
- // add %x, (1 << (KeptBits-1))) DstPred (1 << KeptBits)
- Value *T1 = Builder.CreateICmp(DstPred, T0, ConstantInt::get(XType, ICmpCst));
-
- return T1;
-}
-
/// Try to fold icmp (binop), X or icmp X, (binop).
/// TODO: A large part of this logic is duplicated in InstSimplify's
/// simplifyICmpWithBinOp(). We should be able to share that and avoid the code
@@ -3351,9 +3285,6 @@ Instruction *InstCombiner::foldICmpBinOp(ICmpInst &I) {
if (Value *V = foldICmpWithLowBitMaskedVal(I, Builder))
return replaceInstUsesWith(I, V);
- if (Value *V = foldICmpWithTruncSignExtendedVal(I, Builder))
- return replaceInstUsesWith(I, V);
-
return nullptr;
}
OpenPOWER on IntegriCloud