[llvm] [AMDGPU] Handle negated f16 and fp conversion DAG combines (PR #213202)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 31 10:31:20 PDT 2026
================
@@ -940,6 +942,40 @@ SDValue AMDGPUTargetLowering::getNegatedExpression(
return SDValue();
break;
}
+ case ISD::FP16_TO_FP: {
+ // If the Users of the Op can handle the negation, defer it for that Op
+ // and do not handle the conversion
+ if (allUsesHaveSourceMods(Op.getNode()))
+ return SDValue();
+
+ SDValue Src = Op.getOperand(0);
+ EVT VT = Op.getValueType();
+ EVT SrcVT = Src.getValueType();
+ SDLoc SL(Op);
+ Cost = NegatibleCost::Neutral;
+ SDValue Negated = DAG.getNode(ISD::XOR, SL, SrcVT, Src,
+ DAG.getConstant(0x8000, SL, SrcVT));
+ return DAG.getNode(ISD::FP16_TO_FP, SL, VT, Negated);
----------------
arsenm wrote:
I believe the source modifier should fold, so this would be free? Should double check in the test
https://github.com/llvm/llvm-project/pull/213202
More information about the llvm-commits
mailing list