Skip to content

Commit

Permalink
X86: avoid vector-scalar shifts if splat amount is directly a vector …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
Nekotekina committed Apr 21, 2019
1 parent b860b5e commit 99b5284
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/Target/X86/X86ISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24753,6 +24753,16 @@ static SDValue LowerScalarVariableShift(SDValue Op, SelectionDAG &DAG,

if (SDValue BaseShAmt = GetSplatValue(Amt, dl, DAG)) {
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))
Expand Down

0 comments on commit 99b5284

Please sign in to comment.