aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/CodeGenPrepare.cpp
diff options
context:
space:
mode:
authorQuentin Colombet <qcolombet@apple.com>2014-09-15 18:26:58 +0000
committerQuentin Colombet <qcolombet@apple.com>2014-09-15 18:26:58 +0000
commit9dcb724d311456e1db023dde9aead5968e87f160 (patch)
tree2cd04194c51d4470adf7b8e3c99332ddc27a67f8 /llvm/lib/CodeGen/CodeGenPrepare.cpp
parent760814a7e16547edd7040c823ea38469942269ef (diff)
downloadllvm-9dcb724d311456e1db023dde9aead5968e87f160.zip
llvm-9dcb724d311456e1db023dde9aead5968e87f160.tar.gz
llvm-9dcb724d311456e1db023dde9aead5968e87f160.tar.bz2
[CodeGenPrepare][AddressingModeMatcher] Fix a think-o for the sext(zext) -> zext promotion
introduced in r217629. We were returning the old sext instead of the new zext as the promoted instruction! Thanks Joerg Sonnenberger for the test case. llvm-svn: 217800
Diffstat (limited to 'llvm/lib/CodeGen/CodeGenPrepare.cpp')
-rw-r--r--llvm/lib/CodeGen/CodeGenPrepare.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index c8d203d..5547632 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -1849,6 +1849,7 @@ Value *TypePromotionHelper::promoteOperandForTruncAndAnyExt(
// By construction, the operand of SExt is an instruction. Otherwise we cannot
// get through it and this method should not be called.
Instruction *SExtOpnd = cast<Instruction>(SExt->getOperand(0));
+ Instruction *ExtInst = SExt;
if (isa<ZExtInst>(SExtOpnd)) {
// Replace sext(zext(opnd))
// => zext(opnd).
@@ -1856,6 +1857,7 @@ Value *TypePromotionHelper::promoteOperandForTruncAndAnyExt(
TPT.createZExt(SExt, SExtOpnd->getOperand(0), SExt->getType());
TPT.replaceAllUsesWith(SExt, ZExt);
TPT.eraseInstruction(SExt);
+ ExtInst = ZExt;
} else {
// Replace sext(trunc(opnd)) or sext(sext(opnd))
// => sext(opnd).
@@ -1867,14 +1869,14 @@ Value *TypePromotionHelper::promoteOperandForTruncAndAnyExt(
if (SExtOpnd->use_empty())
TPT.eraseInstruction(SExtOpnd);
- // Check if the sext is still needed.
- if (SExt->getType() != SExt->getOperand(0)->getType())
- return SExt;
+ // Check if the extension is still needed.
+ if (ExtInst->getType() != ExtInst->getOperand(0)->getType())
+ return ExtInst;
- // At this point we have: sext ty opnd to ty.
- // Reassign the uses of SExt to the opnd and remove SExt.
- Value *NextVal = SExt->getOperand(0);
- TPT.eraseInstruction(SExt, NextVal);
+ // At this point we have: ext ty opnd to ty.
+ // Reassign the uses of ExtInst to the opnd and remove ExtInst.
+ Value *NextVal = ExtInst->getOperand(0);
+ TPT.eraseInstruction(ExtInst, NextVal);
return NextVal;
}