[llvm] [AMDGPU][SDAG] Support source modifiers on select integer operands (PR #147325)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 8 09:01:29 PDT 2025
================
@@ -4830,6 +4830,52 @@ AMDGPUTargetLowering::foldFreeOpFromSelect(TargetLowering::DAGCombinerInfo &DCI,
return SDValue();
}
+static EVT getFloatVT(EVT VT) {
+ EVT FT = MVT::getFloatingPointVT(VT.getScalarSizeInBits());
+ return VT.isVector() ? VT.changeVectorElementType(FT) : FT;
+}
+
+static SDValue getBitwiseToSrcModifierOp(SDValue N,
+ TargetLowering::DAGCombinerInfo &DCI) {
+
+ unsigned Opc = N.getNode()->getOpcode();
+ if (Opc != ISD::AND && Opc != ISD::XOR && Opc != ISD::OR)
+ return SDValue();
+
+ SelectionDAG &DAG = DCI.DAG;
+ SDValue LHS = N->getOperand(0);
+ SDValue RHS = N->getOperand(1);
+ ConstantSDNode *CRHS = isConstOrConstSplat(RHS);
+
+ if (!CRHS)
+ return SDValue();
+
+ EVT VT = RHS.getValueType();
+ EVT FVT = getFloatVT(VT);
+ SDLoc SL = SDLoc(N);
+ SDValue BC = DAG.getNode(ISD::BITCAST, SL, FVT, LHS);
----------------
arsenm wrote:
I'd just inline this into each of the uses instead of speculatively creating a node which may never be used
https://github.com/llvm/llvm-project/pull/147325
More information about the llvm-commits
mailing list