Index: llvm/include/llvm/CodeGen/TargetLowering.h =================================================================== --- llvm/include/llvm/CodeGen/TargetLowering.h +++ llvm/include/llvm/CodeGen/TargetLowering.h @@ -4315,7 +4315,8 @@ /// \param N Node to expand /// \param Result output after conversion /// \returns True, if the expansion was successful, false otherwise - bool expandROT(SDNode *N, SDValue &Result, SelectionDAG &DAG) const; + bool expandROT(SDNode *N, bool IsVectorLowering, SDValue &Result, + SelectionDAG &DAG) const; /// Expand float(f32) to SINT(i64) conversion /// \param N Node to expand Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp =================================================================== --- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -3514,7 +3514,7 @@ break; case ISD::ROTL: case ISD::ROTR: - if (TLI.expandROT(Node, Tmp1, DAG)) + if (TLI.expandROT(Node, false, Tmp1, DAG)) Results.push_back(Tmp1); break; case ISD::SADDSAT: Index: llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp =================================================================== --- llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp +++ llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp @@ -1122,7 +1122,7 @@ SDValue DAGTypeLegalizer::PromoteIntRes_Rotate(SDNode *N) { // Lower the rotate to shifts and ORs which can be promoted. SDValue Res; - TLI.expandROT(N, Res, DAG); + TLI.expandROT(N, false, Res, DAG); ReplaceValueWith(SDValue(N, 0), Res); return SDValue(); } @@ -4068,7 +4068,7 @@ SDValue &Lo, SDValue &Hi) { // Lower the rotate to shifts and ORs which can be expanded. SDValue Res; - TLI.expandROT(N, Res, DAG); + TLI.expandROT(N, false, Res, DAG); SplitInteger(Res, Lo, Hi); } Index: llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp =================================================================== --- llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp +++ llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp @@ -796,7 +796,7 @@ break; case ISD::ROTL: case ISD::ROTR: - if (TLI.expandROT(Node, Tmp, DAG)) { + if (TLI.expandROT(Node, true, Tmp, DAG)) { Results.push_back(Tmp); return; } Index: llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp =================================================================== --- llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp @@ -6269,8 +6269,8 @@ } // TODO: Merge with expandFunnelShift. -bool TargetLowering::expandROT(SDNode *Node, SDValue &Result, - SelectionDAG &DAG) const { +bool TargetLowering::expandROT(SDNode *Node, bool IsVectorLowering, + SDValue &Result, SelectionDAG &DAG) const { EVT VT = Node->getValueType(0); unsigned EltSizeInBits = VT.getScalarSizeInBits(); bool IsLeft = Node->getOpcode() == ISD::ROTL; @@ -6289,7 +6289,7 @@ return true; } - if (VT.isVector() && (!isOperationLegalOrCustom(ISD::SHL, VT) || + if (IsVectorLowering && (!isOperationLegalOrCustom(ISD::SHL, VT) || !isOperationLegalOrCustom(ISD::SRL, VT) || !isOperationLegalOrCustom(ISD::SUB, VT) || !isOperationLegalOrCustomOrPromote(ISD::OR, VT) || Index: llvm/test/CodeGen/AArch64/expand-vector-rot.ll =================================================================== --- /dev/null +++ llvm/test/CodeGen/AArch64/expand-vector-rot.ll @@ -0,0 +1,11 @@ +; RUN: llc < %s -mtriple=aarch64-linux-android | FileCheck %s + +declare <2 x i16> @llvm.fshl.v2i16(<2 x i16>, <2 x i16>, <2 x i16>) + +define <2 x i16> @rotlv2_16(<2 x i16> %vec2_16, <2 x i16> %shift) { +; CHECK-LABEL: rotlv2_16: +; CHECK: ushl v +; CHECK: ushl v + %1 = call <2 x i16> @llvm.fshl.v2i16(<2 x i16> %vec2_16, <2 x i16> %vec2_16, <2 x i16> %shift) + ret <2 x i16> %1 +}