Legalizer: Make bswap promotion safe for vectors.

llvm-svn: 209202
This commit is contained in:
Benjamin Kramer 2014-05-20 09:42:31 +00:00
parent 9cb4090867
commit 7bd6bee385
2 changed files with 19 additions and 2 deletions

View File

@ -268,9 +268,9 @@ SDValue DAGTypeLegalizer::PromoteIntRes_BSWAP(SDNode *N) {
EVT NVT = Op.getValueType(); EVT NVT = Op.getValueType();
SDLoc dl(N); SDLoc dl(N);
unsigned DiffBits = NVT.getSizeInBits() - OVT.getSizeInBits(); unsigned DiffBits = NVT.getScalarSizeInBits() - OVT.getScalarSizeInBits();
return DAG.getNode(ISD::SRL, dl, NVT, DAG.getNode(ISD::BSWAP, dl, NVT, Op), return DAG.getNode(ISD::SRL, dl, NVT, DAG.getNode(ISD::BSWAP, dl, NVT, Op),
DAG.getConstant(DiffBits, TLI.getPointerTy())); DAG.getConstant(DiffBits, TLI.getShiftAmountTy(NVT)));
} }
SDValue DAGTypeLegalizer::PromoteIntRes_BUILD_PAIR(SDNode *N) { SDValue DAGTypeLegalizer::PromoteIntRes_BUILD_PAIR(SDNode *N) {

View File

@ -122,6 +122,23 @@ entry:
; CHECK-AVX2-NEXT: retq ; CHECK-AVX2-NEXT: retq
} }
declare <4 x i16> @llvm.bswap.v4i16(<4 x i16>)
define <4 x i16> @test7(<4 x i16> %v) #0 {
entry:
%r = call <4 x i16> @llvm.bswap.v4i16(<4 x i16> %v)
ret <4 x i16> %r
; CHECK-SSSE3-LABEL: @test7
; CHECK-SSSE3: pshufb
; CHECK-SSSE3: psrld $16
; CHECK-SSSE3-NEXT: retq
; CHECK-AVX2-LABEL: @test7
; CHECK-AVX2: vpshufb
; CHECK-AVX2: vpsrld $16
; CHECK-AVX2-NEXT: retq
}
attributes #0 = { nounwind uwtable } attributes #0 = { nounwind uwtable }