[llvm] [AArch64] Remove superfluous sxtw in peephole opt (PR #96293)
Sam Tebbs via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 25 08:33:05 PDT 2024
================
@@ -690,6 +691,33 @@ bool AArch64MIPeepholeOpt::visitFMOVDr(MachineInstr &MI) {
return true;
}
+// Acrocss a basic-block we might have in i32 extract from a value that only
+// operates on upper bits (for example a sxtw). We can replace the COPY with a
+// new version skipping the sxtw.
+bool AArch64MIPeepholeOpt::visitCopy(MachineInstr &MI) {
+ if (MI.getOperand(1).getSubReg() != AArch64::sub_32 ||
+ !MRI->hasOneNonDBGUse(MI.getOperand(1).getReg()))
+ return false;
+
+ MachineInstr *SrcMI = MRI->getUniqueVRegDef(MI.getOperand(1).getReg());
+ MachineInstr *CopyMI = SrcMI;
+ if (SrcMI && SrcMI->isFullCopy() &&
+ MRI->hasOneNonDBGUse(SrcMI->getOperand(1).getReg()))
+ SrcMI = MRI->getUniqueVRegDef(SrcMI->getOperand(1).getReg());
----------------
SamTebbs33 wrote:
Could there be more copies in the chain (i.e. `SrcMI` could be a COPY after line 706). A while loop would eventually get to the end of a long copy chain.
https://github.com/llvm/llvm-project/pull/96293
More information about the llvm-commits
mailing list