[llvm] X86: make VBMI2 funnel shifts use VSHLD/VSHRD for const splats (PR #169401)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 26 11:22:14 PST 2025
================
@@ -57622,6 +57626,41 @@ static SDValue combineFP_TO_xINT_SAT(SDNode *N, SelectionDAG &DAG,
return SDValue();
}
+// Combiner: turn uniform-constant splat funnel shifts into VSHLD/VSHRD
+static SDValue combineFunnelShift(SDNode *N, SelectionDAG &DAG,
+ TargetLowering::DAGCombinerInfo &DCI,
+ const X86Subtarget &Subtarget) {
+ SDLoc DL(N);
+ SDValue Op0 = N->getOperand(0);
+ SDValue Op1 = N->getOperand(1);
+ SDValue Amt = N->getOperand(2);
+ EVT VT = Op0.getValueType();
+
+ if (!VT.isVector())
+ return SDValue();
+
+ // Only combine if the operation is legal for this type.
+ // This ensures we don't try to convert types that need to be
+ // widened/promoted.
+ if (!DAG.getTargetLoweringInfo().isOperationLegal(N->getOpcode(), VT))
----------------
ArnavM3434 wrote:
I tried replacing the isOperationLegal check with the DCI.isBeforeLegalizeDAG() check, but it fails cases like this:
vector-fshl-sub128.ll
define <2 x i32> @splatconstant_funnnel_v2i32(<2 x i32> %x, <2 x i32> %y) {
%res = call <2 x i32> @llvm.fshl.v2i32(<2 x i32> %x, <2 x i32> %y, <2 x i32> <i32 4, i32 4>)
ret <2 x i32> %res
}
Without isOperationLegal is tries to combine the illegal type v2i32. isBeforeLegalizeDAG() doesn't catch this
https://github.com/llvm/llvm-project/pull/169401
More information about the llvm-commits
mailing list