aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2015-09-09 20:20:08 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2015-09-09 20:20:08 +0000
commitd34dbf07bdbe022cc9e96f5de2ac315ec4b20373 (patch)
tree8c4da27dacf3346742871935ade1c736821087e7 /llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
parent65e742a34f12662cfc3edbea097ab4444157bc3b (diff)
downloadllvm-d34dbf07bdbe022cc9e96f5de2ac315ec4b20373.zip
llvm-d34dbf07bdbe022cc9e96f5de2ac315ec4b20373.tar.gz
llvm-d34dbf07bdbe022cc9e96f5de2ac315ec4b20373.tar.bz2
Revert trunc(lshr (sext A), Cst) to ashr A, Cst
This reverts commit r246997, it introduced a regression (PR24763). llvm-svn: 247180
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp20
1 files changed, 0 insertions, 20 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
index fabf80b..768616f 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
@@ -498,26 +498,6 @@ Instruction *InstCombiner::visitTrunc(TruncInst &CI) {
return CastInst::CreateIntegerCast(Shift, CI.getType(), false);
}
- // Transform trunc(lshr (sext A), Cst) to ashr A, Cst to eliminate type
- // conversion.
- // It works because bits coming from sign extension have the same value as
- // sign bit of the original value; performing ashr instead of lshr
- // generates bits of the same value as the sign bit.
- if (Src->hasOneUse() &&
- match(Src, m_LShr(m_SExt(m_Value(A)), m_ConstantInt(Cst))) &&
- cast<Instruction>(Src)->getOperand(0)->hasOneUse()) {
- const unsigned ASize = A->getType()->getPrimitiveSizeInBits();
- // This optimization can be only performed when zero bits generated by
- // the original lshr aren't pulled into the value after truncation, so we
- // can only shift by values smaller then the size of destination type (in
- // bits).
- if (Cst->getValue().ult(ASize)) {
- Value *Shift = Builder->CreateAShr(A, Cst->getZExtValue());
- Shift->takeName(Src);
- return CastInst::CreateIntegerCast(Shift, CI.getType(), false);
- }
- }
-
// Transform "trunc (and X, cst)" -> "and (trunc X), cst" so long as the dest
// type isn't non-native.
if (Src->hasOneUse() && isa<IntegerType>(Src->getType()) &&