Skip to content

Commit 99b5284

Browse files
committed
X86: avoid vector-scalar shifts if splat amount is directly a vector ADD/SUB/AND op.
Prefer vector-vector shifts if available (AVX2+). Improves code generated for rotate and funnel shifts. Otherwise it would generate a shuffle + slower vector-scalar shift.
1 parent b860b5e commit 99b5284

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/Target/X86/X86ISelLowering.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -24753,6 +24753,16 @@ static SDValue LowerScalarVariableShift(SDValue Op, SelectionDAG &DAG,
2475324753

2475424754
if (SDValue BaseShAmt = GetSplatValue(Amt, dl, DAG)) {
2475524755
if (SupportedVectorShiftWithBaseAmnt(VT, Subtarget, Opcode)) {
24756+
if (SupportedVectorVarShift(VT, Subtarget, Opcode)) {
24757+
// Avoid vector-scalar shift in some cases (TODO).
24758+
unsigned AmtOp = Amt.getOpcode();
24759+
switch (AmtOp) {
24760+
case ISD::ADD:
24761+
case ISD::SUB:
24762+
case ISD::AND:
24763+
return SDValue();
24764+
}
24765+
}
2475624766
MVT EltVT = VT.getVectorElementType();
2475724767
assert(EltVT.bitsLE(MVT::i64) && "Unexpected element type!");
2475824768
if (EltVT != MVT::i64 && EltVT.bitsGT(MVT::i32))

0 commit comments

Comments
 (0)