[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());
----------------
SamTebbs33 wrote:
A minor improvement is storing `MI->getOperand(1)` to a variable rather than calling `getOperand()` a few times.
https://github.com/llvm/llvm-project/pull/96293
More information about the llvm-commits
mailing list