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

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 14 01:31:26 PDT 2024


================
@@ -8219,6 +8223,19 @@ LegalizerHelper::lowerAbsToMaxNeg(MachineInstr &MI) {
   return Legalized;
 }
 
+LegalizerHelper::LegalizeResult
+LegalizerHelper::lowerAbsToCNeg(MachineInstr &MI) {
+  Register SrcReg = MI.getOperand(1).getReg();
+  Register DestReg = MI.getOperand(0).getReg();
+  LLT Ty = MRI.getType(SrcReg);
+  auto Zero = MIRBuilder.buildConstant(Ty, 0).getReg(0);
+  auto Sub = MIRBuilder.buildSub(Ty, Zero, SrcReg).getReg(0);
----------------
arsenm wrote:

```suggestion
  auto Zero = MIRBuilder.buildConstant(Ty, 0);
  auto Sub = MIRBuilder.buildSub(Ty, Zero, SrcReg);
```

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


More information about the llvm-commits mailing list