[llvm] [AArch64][GlobalISel] Legalize 128-bit types for FABS (PR #104753)

via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 19 06:55:52 PDT 2024


================
@@ -1396,6 +1412,25 @@ bool AArch64LegalizerInfo::legalizeFunnelShift(MachineInstr &MI,
   return true;
 }
 
+bool AArch64LegalizerInfo::legalizeFABS(MachineInstr &MI,
+                                        MachineRegisterInfo &MRI,
+                                        MachineIRBuilder &MIRBuilder) const {
+  Register SrcReg = MI.getOperand(1).getReg();
+  Register DstReg = MI.getOperand(0).getReg();
+
+  constexpr LLT S128 = LLT::scalar(128);
+  if (MRI.getType(SrcReg) != S128 || MRI.getType(DstReg) != S128)
+    return false;
+
+  MIRBuilder.buildAnd(
+      DstReg, SrcReg,
+      MIRBuilder.buildConstant(
+          S128, APInt::getSignedMaxValue(128)));
----------------
Him188 wrote:

I failed to find such a handling. `lowerFor({128})` also failed without adding a lower action. So I think there isn't a default lower action for G_FABS.

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


More information about the llvm-commits mailing list