Index: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp =================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp @@ -21387,7 +21387,7 @@ bool LShift = VT.is128BitVector() || (VT.is256BitVector() && Subtarget.hasInt256()); - bool AShift = LShift && (Subtarget.hasVLX() || + bool AShift = LShift && (Subtarget.hasAVX512() || (VT != MVT::v2i64 && VT != MVT::v4i64)); return (Opcode == ISD::SRA) ? AShift : LShift; } Index: llvm/trunk/lib/Target/X86/X86InstrAVX512.td =================================================================== --- llvm/trunk/lib/Target/X86/X86InstrAVX512.td +++ llvm/trunk/lib/Target/X86/X86InstrAVX512.td @@ -4798,6 +4798,33 @@ defm VPSRA : avx512_shift_types<0xE2, 0xE2, 0xE1, "vpsra", X86vsra>; defm VPSRL : avx512_shift_types<0xD2, 0xD3, 0xD1, "vpsrl", X86vsrl>; +// Use 512bit VPSRA/VPSRAI version to implement v2i64/v4i64 in case NoVLX. +let Predicates = [HasAVX512, NoVLX] in { + def : Pat<(v4i64 (X86vsra (v4i64 VR256X:$src1), (v2i64 VR128X:$src2))), + (EXTRACT_SUBREG (v8i64 + (VPSRAQZrr + (v8i64 (INSERT_SUBREG (IMPLICIT_DEF), VR256X:$src1, sub_ymm)), + VR128X:$src2)), sub_ymm)>; + + def : Pat<(v2i64 (X86vsra (v2i64 VR128X:$src1), (v2i64 VR128X:$src2))), + (EXTRACT_SUBREG (v8i64 + (VPSRAQZrr + (v8i64 (INSERT_SUBREG (IMPLICIT_DEF), VR128X:$src1, sub_xmm)), + VR128X:$src2)), sub_xmm)>; + + def : Pat<(v4i64 (X86vsrai (v4i64 VR256X:$src1), (i8 imm:$src2))), + (EXTRACT_SUBREG (v8i64 + (VPSRAQZri + (v8i64 (INSERT_SUBREG (IMPLICIT_DEF), VR256X:$src1, sub_ymm)), + imm:$src2)), sub_ymm)>; + + def : Pat<(v2i64 (X86vsrai (v2i64 VR128X:$src1), (i8 imm:$src2))), + (EXTRACT_SUBREG (v8i64 + (VPSRAQZri + (v8i64 (INSERT_SUBREG (IMPLICIT_DEF), VR128X:$src1, sub_xmm)), + imm:$src2)), sub_xmm)>; +} + //===-------------------------------------------------------------------===// // Variable Bit Shifts //===-------------------------------------------------------------------===// Index: llvm/trunk/test/CodeGen/X86/avx512-ext.ll =================================================================== --- llvm/trunk/test/CodeGen/X86/avx512-ext.ll +++ llvm/trunk/test/CodeGen/X86/avx512-ext.ll @@ -491,8 +491,7 @@ ; KNL-LABEL: zext_2x8mem_to_2x64: ; KNL: ## BB#0: ; KNL-NEXT: vpsllq $63, %xmm0, %xmm0 -; KNL-NEXT: vpsrad $31, %xmm0, %xmm0 -; KNL-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[1,1,3,3] +; KNL-NEXT: vpsraq $63, %zmm0, %zmm0 ; KNL-NEXT: vpmovzxbq {{.*#+}} xmm1 = mem[0],zero,zero,zero,zero,zero,zero,zero,mem[1],zero,zero,zero,zero,zero,zero,zero ; KNL-NEXT: vpand %xmm1, %xmm0, %xmm0 ; KNL-NEXT: retq @@ -512,8 +511,7 @@ ; KNL-LABEL: sext_2x8mem_to_2x64mask: ; KNL: ## BB#0: ; KNL-NEXT: vpsllq $63, %xmm0, %xmm0 -; KNL-NEXT: vpsrad $31, %xmm0, %xmm0 -; KNL-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[1,1,3,3] +; KNL-NEXT: vpsraq $63, %zmm0, %zmm0 ; KNL-NEXT: vpmovsxbq (%rdi), %xmm1 ; KNL-NEXT: vpand %xmm1, %xmm0, %xmm0 ; KNL-NEXT: retq @@ -872,8 +870,7 @@ ; KNL-LABEL: zext_2x16mem_to_2x64: ; KNL: ## BB#0: ; KNL-NEXT: vpsllq $63, %xmm0, %xmm0 -; KNL-NEXT: vpsrad $31, %xmm0, %xmm0 -; KNL-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[1,1,3,3] +; KNL-NEXT: vpsraq $63, %zmm0, %zmm0 ; KNL-NEXT: vpmovzxwq {{.*#+}} xmm1 = mem[0],zero,zero,zero,mem[1],zero,zero,zero ; KNL-NEXT: vpand %xmm1, %xmm0, %xmm0 ; KNL-NEXT: retq @@ -894,8 +891,7 @@ ; KNL-LABEL: sext_2x16mem_to_2x64mask: ; KNL: ## BB#0: ; KNL-NEXT: vpsllq $63, %xmm0, %xmm0 -; KNL-NEXT: vpsrad $31, %xmm0, %xmm0 -; KNL-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[1,1,3,3] +; KNL-NEXT: vpsraq $63, %zmm0, %zmm0 ; KNL-NEXT: vpmovsxwq (%rdi), %xmm1 ; KNL-NEXT: vpand %xmm1, %xmm0, %xmm0 ; KNL-NEXT: retq @@ -1061,8 +1057,7 @@ ; KNL-LABEL: zext_2x32mem_to_2x64: ; KNL: ## BB#0: ; KNL-NEXT: vpsllq $63, %xmm0, %xmm0 -; KNL-NEXT: vpsrad $31, %xmm0, %xmm0 -; KNL-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[1,1,3,3] +; KNL-NEXT: vpsraq $63, %zmm0, %zmm0 ; KNL-NEXT: vpmovzxdq {{.*#+}} xmm1 = mem[0],zero,mem[1],zero ; KNL-NEXT: vpand %xmm1, %xmm0, %xmm0 ; KNL-NEXT: retq @@ -1083,8 +1078,7 @@ ; KNL-LABEL: sext_2x32mem_to_2x64mask: ; KNL: ## BB#0: ; KNL-NEXT: vpsllq $63, %xmm0, %xmm0 -; KNL-NEXT: vpsrad $31, %xmm0, %xmm0 -; KNL-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[1,1,3,3] +; KNL-NEXT: vpsraq $63, %zmm0, %zmm0 ; KNL-NEXT: vpmovsxdq (%rdi), %xmm1 ; KNL-NEXT: vpand %xmm1, %xmm0, %xmm0 ; KNL-NEXT: retq Index: llvm/trunk/test/CodeGen/X86/avx512dq-intrinsics-upgrade.ll =================================================================== --- llvm/trunk/test/CodeGen/X86/avx512dq-intrinsics-upgrade.ll +++ llvm/trunk/test/CodeGen/X86/avx512dq-intrinsics-upgrade.ll @@ -18,8 +18,7 @@ ; CHECK-NEXT: vmovq %rax, %xmm3 ; CHECK-NEXT: vpunpcklqdq {{.*#+}} xmm2 = xmm3[0],xmm2[0] ; CHECK-NEXT: vpsllq $63, %xmm2, %xmm2 -; CHECK-NEXT: vpsrad $31, %xmm2, %xmm2 -; CHECK-NEXT: vpshufd {{.*#+}} xmm2 = xmm2[1,1,3,3] +; CHECK-NEXT: vpsraq $63, %zmm2, %zmm2 ; CHECK-NEXT: vblendvpd %xmm2, %xmm0, %xmm1, %xmm1 ; CHECK-NEXT: vandpd %xmm0, %xmm2, %xmm2 ; CHECK-NEXT: vaddpd %xmm0, %xmm1, %xmm0 Index: llvm/trunk/test/CodeGen/X86/compress_expand.ll =================================================================== --- llvm/trunk/test/CodeGen/X86/compress_expand.ll +++ llvm/trunk/test/CodeGen/X86/compress_expand.ll @@ -200,8 +200,7 @@ ; KNL: # BB#0: ; KNL-NEXT: # kill: %XMM0 %XMM0 %ZMM0 ; KNL-NEXT: vpsllq $63, %xmm1, %xmm1 -; KNL-NEXT: vpsrad $31, %xmm1, %xmm1 -; KNL-NEXT: vpshufd {{.*#+}} xmm1 = xmm1[1,1,3,3] +; KNL-NEXT: vpsraq $63, %zmm1, %zmm1 ; KNL-NEXT: vpxord %zmm2, %zmm2, %zmm2 ; KNL-NEXT: vinserti32x4 $0, %xmm1, %zmm2, %zmm1 ; KNL-NEXT: vpsllq $63, %zmm1, %zmm1 Index: llvm/trunk/test/CodeGen/X86/vector-shift-ashr-128.ll =================================================================== --- llvm/trunk/test/CodeGen/X86/vector-shift-ashr-128.ll +++ llvm/trunk/test/CodeGen/X86/vector-shift-ashr-128.ll @@ -649,8 +649,7 @@ ; AVX512-LABEL: splatvar_shift_v2i64: ; AVX512: # BB#0: ; AVX512-NEXT: # kill: %XMM0 %XMM0 %ZMM0 -; AVX512-NEXT: vpbroadcastq %xmm1, %xmm1 -; AVX512-NEXT: vpsravq %zmm1, %zmm0, %zmm0 +; AVX512-NEXT: vpsraq %xmm1, %zmm0, %zmm0 ; AVX512-NEXT: # kill: %XMM0 %XMM0 %ZMM0 ; AVX512-NEXT: retq ; @@ -1556,9 +1555,9 @@ ; ; AVX512-LABEL: splatconstant_shift_v2i64: ; AVX512: # BB#0: -; AVX512-NEXT: vpsrad $7, %xmm0, %xmm1 -; AVX512-NEXT: vpsrlq $7, %xmm0, %xmm0 -; AVX512-NEXT: vpblendd {{.*#+}} xmm0 = xmm0[0],xmm1[1],xmm0[2],xmm1[3] +; AVX512-NEXT: # kill: %XMM0 %XMM0 %ZMM0 +; AVX512-NEXT: vpsraq $7, %zmm0, %zmm0 +; AVX512-NEXT: # kill: %XMM0 %XMM0 %ZMM0 ; AVX512-NEXT: retq ; ; AVX512VL-LABEL: splatconstant_shift_v2i64: Index: llvm/trunk/test/CodeGen/X86/vector-shift-ashr-256.ll =================================================================== --- llvm/trunk/test/CodeGen/X86/vector-shift-ashr-256.ll +++ llvm/trunk/test/CodeGen/X86/vector-shift-ashr-256.ll @@ -491,8 +491,7 @@ ; AVX512-LABEL: splatvar_shift_v4i64: ; AVX512: # BB#0: ; AVX512-NEXT: # kill: %YMM0 %YMM0 %ZMM0 -; AVX512-NEXT: vpbroadcastq %xmm1, %ymm1 -; AVX512-NEXT: vpsravq %zmm1, %zmm0, %zmm0 +; AVX512-NEXT: vpsraq %xmm1, %zmm0, %zmm0 ; AVX512-NEXT: # kill: %YMM0 %YMM0 %ZMM0 ; AVX512-NEXT: retq ; @@ -1198,9 +1197,9 @@ ; ; AVX512-LABEL: splatconstant_shift_v4i64: ; AVX512: # BB#0: -; AVX512-NEXT: vpsrad $7, %ymm0, %ymm1 -; AVX512-NEXT: vpsrlq $7, %ymm0, %ymm0 -; AVX512-NEXT: vpblendd {{.*#+}} ymm0 = ymm0[0],ymm1[1],ymm0[2],ymm1[3],ymm0[4],ymm1[5],ymm0[6],ymm1[7] +; AVX512-NEXT: # kill: %YMM0 %YMM0 %ZMM0 +; AVX512-NEXT: vpsraq $7, %zmm0, %zmm0 +; AVX512-NEXT: # kill: %YMM0 %YMM0 %ZMM0 ; AVX512-NEXT: retq ; ; AVX512VL-LABEL: splatconstant_shift_v4i64: