[llvm] [RISCV][GISel] Lower G_ABDS and G_ABDU (PR #155888)

Shaoce SUN via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 4 10:05:13 PDT 2025


================
@@ -4742,6 +4755,18 @@ LegalizerHelper::lower(MachineInstr &MI, unsigned TypeIdx, LLT LowerHintTy) {
     return lowerShlSat(MI);
   case G_ABS:
     return lowerAbsToAddXor(MI);
+  case G_ABDS: {
+    LLT Ty = MRI.getType(MI.getOperand(0).getReg());
+    if (LI.isLegal({G_SMIN, Ty}) && LI.isLegal({G_SMAX, Ty}))
+      return lowerAbsDiffToMinMax(MI);
+  }
----------------
sunshaoce wrote:

Thanks for pointing this out! I’ve merged the two cases as well.

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


More information about the llvm-commits mailing list