aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/CodeGenPrepare.cpp
diff options
context:
space:
mode:
authorYingwei Zheng <dtcxzyw2333@gmail.com>2025-01-30 08:58:23 +0800
committerGitHub <noreply@github.com>2025-01-30 08:58:23 +0800
commit3c6aa04cf4dee65113e2a780b9f90b36bb4c4e04 (patch)
tree75cf23ad67d36d57ff2f0fd2ea6ad56e7559020b /llvm/lib/CodeGen/CodeGenPrepare.cpp
parent69c24684f66dda2e804853baf178ec16cb14fe8f (diff)
downloadllvm-3c6aa04cf4dee65113e2a780b9f90b36bb4c4e04.zip
llvm-3c6aa04cf4dee65113e2a780b9f90b36bb4c4e04.tar.gz
llvm-3c6aa04cf4dee65113e2a780b9f90b36bb4c4e04.tar.bz2
[CodeGenPrepare] Replace deleted ext instr with the promoted value. (#71058)
This PR replaces the deleted ext with the promoted value in `AddrMode`. Fixes #70938.
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: