diff options
| author | Simon Pilgrim <llvm-dev@redking.me.uk> | 2018-03-09 18:37:56 +0000 |
|---|---|---|
| committer | Simon Pilgrim <llvm-dev@redking.me.uk> | 2018-03-09 18:37:56 +0000 |
| commit | 2cd489feb2b99d1a24aab4c8971ae528e0b77d78 (patch) | |
| tree | 45d4f04fb8244c3200215706b091ff06f031bc4f /llvm | |
| parent | 169ec09cb7077cc7be74460a371dafa2cecb2f95 (diff) | |
| download | bcm5719-llvm-2cd489feb2b99d1a24aab4c8971ae528e0b77d78.tar.gz bcm5719-llvm-2cd489feb2b99d1a24aab4c8971ae528e0b77d78.zip | |
[X86][AVX] createVariablePermute - fix v2i64/v2f64 VPERMILPD index creation.
The input indices vector will put the index in bit0, but VPERMILPD actually selects off bit1 - so we need to scale accordingly.
llvm-svn: 327159
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/Target/X86/X86ISelLowering.cpp | 2 | ||||
| -rw-r--r-- | llvm/test/CodeGen/X86/var-permute-128.ll | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index e8265e7e643..b5649707cc5 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -7963,6 +7963,8 @@ SDValue createVariablePermute(MVT VT, SDValue SrcVec, SDValue IndicesVec, case MVT::v2f64: case MVT::v2i64: if (Subtarget.hasAVX()) { + // VPERMILPD selects using bit#1 of the index vector, so scale IndicesVec. + IndicesVec = DAG.getNode(ISD::ADD, DL, IndicesVT, IndicesVec, IndicesVec); Opcode = X86ISD::VPERMILPV; ShuffleVT = MVT::v2f64; } diff --git a/llvm/test/CodeGen/X86/var-permute-128.ll b/llvm/test/CodeGen/X86/var-permute-128.ll index 1b00c428281..178931939aa 100644 --- a/llvm/test/CodeGen/X86/var-permute-128.ll +++ b/llvm/test/CodeGen/X86/var-permute-128.ll @@ -37,6 +37,7 @@ define <2 x i64> @var_shuffle_v2i64(<2 x i64> %v, <2 x i64> %indices) nounwind { ; ; AVX-LABEL: var_shuffle_v2i64: ; AVX: # %bb.0: +; AVX-NEXT: vpaddq %xmm1, %xmm1, %xmm1 ; AVX-NEXT: vpermilpd %xmm1, %xmm0, %xmm0 ; AVX-NEXT: retq %index0 = extractelement <2 x i64> %indices, i32 0 @@ -221,6 +222,7 @@ define <2 x double> @var_shuffle_v2f64(<2 x double> %v, <2 x i64> %indices) noun ; ; AVX-LABEL: var_shuffle_v2f64: ; AVX: # %bb.0: +; AVX-NEXT: vpaddq %xmm1, %xmm1, %xmm1 ; AVX-NEXT: vpermilpd %xmm1, %xmm0, %xmm0 ; AVX-NEXT: retq %index0 = extractelement <2 x i64> %indices, i32 0 |

