aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/CodeGenPrepare.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/CodeGenPrepare.cpp')
-rw-r--r--llvm/lib/CodeGen/CodeGenPrepare.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index 47486a3..088062afa 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -3074,6 +3074,14 @@ struct ExtAddrMode : public TargetLowering::AddrMode {
void print(raw_ostream &OS) const;
void dump() const;
+ // Replace From in ExtAddrMode with To.
+ // E.g., SExt insts may be promoted and deleted. We should replace them with
+ // the promoted values.
+ void replaceWith(Value *From, Value *To) {
+ if (ScaledReg == From)
+ ScaledReg = To;
+ }
+
FieldName compare(const ExtAddrMode &other) {
// First check that the types are the same on each field, as differing types
// is something we can't cope with later on.
@@ -5365,6 +5373,9 @@ bool AddressingModeMatcher::matchOperationAddr(User *AddrInst, unsigned Opcode,
TPT.rollback(LastKnownGood);
return false;
}
+
+ // SExt has been deleted. Make sure it is not referenced by the AddrMode.
+ AddrMode.replaceWith(Ext, PromotedOperand);
return true;
}
case Instruction::Call: