[llvm] [AMDGPU] Add folding ISD::SELECT from vXiY into vZi32 with X * Y = Z * 32 (PR #173328)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 25 04:01:10 PST 2026
================
@@ -6972,6 +6972,35 @@ static SDValue combineSelectAsExtAnd(SDValue Cond, SDValue T, SDValue F,
return DAG.getNode(ISD::AND, DL, OpVT, CondMask, T.getOperand(0));
}
+// Try to convert vXiY into vZi32 with X * Y = Z * 32
+// This prevent promotion of integer vectors like v32i4 to v32i16
+// which can create extra operations on type casting.
+static SDValue castTypeSelect(SDNode *N, SelectionDAG &DAG,
+ const TargetLowering &TLI, SDValue Cond,
+ SDValue TrueVal, SDValue FalseVal) {
+ EVT ResultVT = N->getValueType(0);
+ if (ResultVT.isSimple() || !ResultVT.isVector() ||
+ !ResultVT.isPow2VectorType() ||
+ TLI.getTypeAction(*DAG.getContext(), ResultVT) !=
+ TargetLowering::TypePromoteInteger)
+ return SDValue();
+
+ EVT EltVT = ResultVT.getVectorElementType();
+ if (!EltVT.isInteger() || ResultVT.getVectorElementCount().isScalar())
+ return SDValue();
+
+ EVT NewVT = ResultVT.getIntegerVectorWithElementWidth(*DAG.getContext(), 32);
+ if (NewVT == EVT())
+ return SDValue();
+
----------------
arsenm wrote:
Check if new type is legal
https://github.com/llvm/llvm-project/pull/173328
More information about the llvm-commits
mailing list