[llvm] [PowerPC] fix `ppc_fp128` `FABS` bug (PR #209286)

Folkert de Vries via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 13 12:55:17 PDT 2026


================
@@ -3058,8 +3058,13 @@ bool TargetLowering::SimplifyDemandedBits(
   }
   case ISD::FABS: {
     SDValue Op0 = Op.getOperand(0);
-    APInt SignMask = APInt::getSignMask(BitWidth);
+    EVT SVT = Op0.getValueType();
+
+    // The position of the sign bit for ppc_fp128 is endian-dependent.
+    if (!APFloat::hasSignBitInMSB(SVT.getFltSemantics()) || SVT == MVT::ppcf128)
+      break;
----------------
folkertdev wrote:

We might be able to do slightly better here, but I'd rather be correct and slightly inefficient for a type that is almost never used than slightly more efficient and potentially subtly wrong.

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


More information about the llvm-commits mailing list