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

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 19 05:46:14 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)));
----------------
arsenm wrote:

This should already be the default lower action. This shouldn't require custom lowering 

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


More information about the llvm-commits mailing list