[Mlir-commits] [clang] [llvm] [mlir] [clang][NVPTX][MLIR][NVVM] Add overloaded fadd intrinsics (PR #217336)
Srinivasa Ravi
llvmlistbot at llvm.org
Wed Aug 26 05:27:39 PDT 2026
================
@@ -7048,24 +7071,67 @@ static SDValue combineF16AddWithNeg(SDNode *N, SelectionDAG &DAG,
return SDValue();
}
- SDLoc DL(N);
- return DAG.getNode(getF16SubOpc(AddIntrinsicID), DL, N->getValueType(0),
- SubOp1, SubOp2);
+ return DAG.getNode(Opc, SDLoc(N), VT, SubOp1, SubOp2);
+}
+
+static bool isSupportedFAdd(EVT VT, const NVPTXSubtarget &STI,
+ Intrinsic::ID IID,
+ APFloat::roundingMode RoundingMode) {
+ if (VT.isVector() && VT.getVectorElementCount() != ElementCount::getFixed(2))
+ return false;
+
+ const bool IsRN = RoundingMode == APFloat::rmNearestTiesToEven;
+ const bool IsFTZ = nvvm::FAddShouldFTZ(IID);
+ const bool IsSat = nvvm::FAddShouldSaturate(IID);
+ switch (VT.getScalarType().getSimpleVT().SimpleTy) {
+ case MVT::f16:
+ return IsRN;
+ case MVT::bf16:
+ return IsRN && !IsSat && !IsFTZ && STI.hasNativeBF16Support(ISD::FADD);
+ case MVT::f32:
+ return !VT.isVector() || (!IsSat && STI.hasF32x2Instructions());
+ case MVT::f64:
+ return !VT.isVector() && !IsSat && !IsFTZ;
+ default:
+ return false;
+ }
+}
+
+static SDValue diagnoseInvalidFAdd(SDNode *N, SelectionDAG &DAG,
----------------
Wolfram70 wrote:
Refactored this slightly in the latest revision. Returning poison here is mainly just to exit gracefully after the compilation files. The type-legality checks here are mostly meant to be temporary until https://github.com/llvm/llvm-project/pull/172442 is merged, adding infra for explicit type constraints in overloaded intrinsics. Add a TODO for that here as well, thanks!
https://github.com/llvm/llvm-project/pull/217336
More information about the Mlir-commits
mailing list