[llvm] r349040 - [X86][SSE] Merge the vXi16/vXi32 vector rotation expansion cases. NFCI.

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 13 06:51:28 PST 2018


Author: rksimon
Date: Thu Dec 13 06:51:28 2018
New Revision: 349040

URL: http://llvm.org/viewvc/llvm-project?rev=349040&view=rev
Log:
[X86][SSE] Merge the vXi16/vXi32 vector rotation expansion cases. NFCI.

Merged the repeated code into a single if().

Modified:
    llvm/trunk/lib/Target/X86/X86ISelLowering.cpp

Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=349040&r1=349039&r2=349040&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Thu Dec 13 06:51:28 2018
@@ -24822,18 +24822,6 @@ static SDValue LowerRotate(SDValue Op, c
     if (BVAmt->getConstantSplatNode())
       return SDValue();
 
-  // TODO: ISD::ROT* uses modulo rotate amounts, we need to handle this.
-
-  // Rotate by splat - expand back to shifts.
-  // TODO - legalizers should be able to handle this.
-  if (EltSizeInBits >= 16 && DAG.isSplatValue(Amt)) {
-    SDValue AmtR = DAG.getConstant(EltSizeInBits, DL, VT);
-    AmtR = DAG.getNode(ISD::SUB, DL, VT, AmtR, Amt);
-    SDValue SHL = DAG.getNode(ISD::SHL, DL, VT, R, Amt);
-    SDValue SRL = DAG.getNode(ISD::SRL, DL, VT, R, AmtR);
-    return DAG.getNode(ISD::OR, DL, VT, SHL, SRL);
-  }
-
   // v16i8/v32i8: Split rotation into rot4/rot2/rot1 stages and select by
   // the amount bit.
   if (EltSizeInBits == 8) {
@@ -24899,10 +24887,12 @@ static SDValue LowerRotate(SDValue Op, c
   bool LegalVarShifts = SupportedVectorVarShift(VT, Subtarget, ISD::SHL) &&
                         SupportedVectorVarShift(VT, Subtarget, ISD::SRL);
 
+  // Rotate by splat - expand back to shifts.
   // Best to fallback for all supported variable shifts.
   // AVX2 - best to fallback for non-constants as well.
   // TODO - legalizers should be able to handle this.
-  if (LegalVarShifts || (Subtarget.hasAVX2() && !ConstantAmt)) {
+  if (LegalVarShifts || (Subtarget.hasAVX2() && !ConstantAmt) ||
+      DAG.isSplatValue(Amt)) {
     SDValue AmtR = DAG.getConstant(EltSizeInBits, DL, VT);
     AmtR = DAG.getNode(ISD::SUB, DL, VT, AmtR, Amt);
     SDValue SHL = DAG.getNode(ISD::SHL, DL, VT, R, Amt);




More information about the llvm-commits mailing list