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

Madhur Amilkanthwar via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 14 22:22:30 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 (LI.isLegalOrCustom({G_ABS, Ty}))
----------------
madhur13490 wrote:

```
LLT Ty = MRI.getType(MI.getOperand(0).getReg());
dbgs() << LI.isLegalOrCustom({G_ICMP, Ty});
```
Leads to an assert for llvm.abs.ll test. This doesn't need my patch to trigger an assert. 
@arsenm Thoughts? 
If this is uncovering a latent issue then I would like to go with legalizeCustom() and follow @davemgreen's suggestion. This also aligns with what RISCV is doing. 

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


More information about the llvm-commits mailing list