[llvm] [RISCV] GISel custom lowering for G_ADD/G_SUB (PR #121587)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 4 11:15:52 PST 2025


================
@@ -1330,6 +1338,25 @@ bool RISCVLegalizerInfo::legalizeCustom(
       return true;
     return Helper.lowerConstant(MI);
   }
+  case TargetOpcode::G_SUB:
+  case TargetOpcode::G_ADD: {
+    Helper.Observer.changingInstr(MI);
+    Helper.widenScalarSrc(MI, LLT::scalar(64), 1, TargetOpcode::G_ANYEXT);
+    Helper.widenScalarSrc(MI, LLT::scalar(64), 2, TargetOpcode::G_ANYEXT);
+
+    Register DstALU = MRI.createGenericVirtualRegister(sXLen);
+    Register DstSext = MRI.createGenericVirtualRegister(sXLen);
----------------
topperc wrote:

I think Matt meant `buildSExtInReg(sXLen, DstALU, 32)`. If you pass an `LLT` as the first operand, it will automatically create the virtual register.

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


More information about the llvm-commits mailing list