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

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 19 03:36:07 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);
----------------
arsenm wrote:

Reusing the same type for the compare result isn't right, but we don't have a great API for this. We kind of want the equivalent of getSetCCResultType. A more awkward solution would be to query with s1 and then look through the legalize actions until you find transforms on the original. Failing that, using i1 as the basis of the query is a more reasonable choice I think 

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


More information about the llvm-commits mailing list