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.
This commit is contained in:
Nekotekina
2019-04-21 12:32:17 +03:00
parent c11d15d9b7
commit 5391c5c3a1

View File

@@ -25619,6 +25619,16 @@ static SDValue LowerScalarVariableShift(SDValue Op, SelectionDAG &DAG,
if (SDValue BaseShAmt = DAG.getSplatValue(Amt)) {
if (SupportedVectorShiftWithBaseAmnt(VT, Subtarget, Opcode)) {
if (SupportedVectorVarShift(VT, Subtarget, Opcode)) {
// Avoid vector-scalar shift in some cases (TODO).
unsigned AmtOp = Amt.getOpcode();
switch (AmtOp) {
case ISD::ADD:
case ISD::SUB:
case ISD::AND:
return SDValue();
}
}
MVT EltVT = VT.getVectorElementType();
assert(EltVT.bitsLE(MVT::i64) && "Unexpected element type!");
if (EltVT != MVT::i64 && EltVT.bitsGT(MVT::i32))