[llvm] [AArch64][GlobalISel] Take abs scalar codegen closer to SDAG (PR #84886)

Madhur Amilkanthwar via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 19 04:58:52 PDT 2024


================
@@ -3914,8 +3914,12 @@ LegalizerHelper::lower(MachineInstr &MI, unsigned TypeIdx, LLT LowerHintTy) {
   case G_SSHLSAT:
   case G_USHLSAT:
     return lowerShlSat(MI);
-  case G_ABS:
+  case G_ABS: {
+    LLT Ty = MRI.getType(MI.getOperand(0).getReg());
+    if (Ty.isScalar() &&  LI.isLegalOrCustom({G_ICMP, {Ty, Ty}}))
+        return lowerAbsToCNeg(MI);
----------------
madhur13490 wrote:

@tschuett How would that handle @arsenm's concern?

I agree with @davemgreen's approach and will update the patch accordingly. I would not like to touch `lower` as of now and handle it in `legalizeCustom`. Given that we don't have the right APIs, the right approach would be handle this separately.


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


More information about the llvm-commits mailing list