[llvm] [AArch64] Fold UBFMXri to UBFMWri when it's an LSR or LSL alias (PR #106968)

Csanád Hajdú via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 5 00:27:19 PDT 2024


================
@@ -715,6 +719,58 @@ bool AArch64MIPeepholeOpt::visitFMOVDr(MachineInstr &MI) {
   return true;
 }
 
+bool AArch64MIPeepholeOpt::visitUBFMXri(MachineInstr &MI) {
+  // Check if the instruction is equivalent to a 32 bit LSR or LSL alias of
+  // UBFM, and replace the UBFMXri instruction with its 32 bit variant, UBFMWri.
+  int64_t Immr = MI.getOperand(2).getImm();
+  int64_t Imms = MI.getOperand(3).getImm();
+
+  bool IsLSR = Imms == 31 && Immr <= Imms;
+  bool IsLSL = Immr == Imms + 33;
+  if (IsLSR || IsLSL) {
----------------
Il-Capitano wrote:

Thanks for catching that, fixed it now.

https://github.com/llvm/llvm-project/pull/106968


More information about the llvm-commits mailing list