1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2; RUN: llc < %s -mtriple=x86_64-unknown -mattr=+avx2 | FileCheck %s --check-prefixes=AVX2,AVX2-SLOW 3; RUN: llc < %s -mtriple=x86_64-unknown -mattr=+avx2,+fast-variable-crosslane-shuffle,+fast-variable-perlane-shuffle | FileCheck %s --check-prefixes=AVX2,AVX2-FAST-ALL 4; RUN: llc < %s -mtriple=x86_64-unknown -mattr=+avx2,+fast-variable-perlane-shuffle | FileCheck %s --check-prefixes=AVX2,AVX2-FAST-PERLANE 5; PR32449 6 7define <2 x double> @foo2(<2 x double> %v, ptr%p) nounwind { 8; AVX2-LABEL: foo2: 9; AVX2: # %bb.0: 10; AVX2-NEXT: vshufpd {{.*#+}} xmm0 = xmm0[1,1] 11; AVX2-NEXT: vmovapd %xmm0, (%rdi) 12; AVX2-NEXT: retq 13 %res = shufflevector <2 x double> %v, <2 x double> undef, <2 x i32> <i32 1, i32 1> 14 %res1 = shufflevector<2 x double> %res, <2 x double> undef, <2 x i32> <i32 1, i32 undef> 15 store <2 x double> %res, ptr %p 16 ret <2 x double> %res1 17} 18 19define <4 x double> @foo4(<4 x double> %v, ptr%p) nounwind { 20; AVX2-LABEL: foo4: 21; AVX2: # %bb.0: 22; AVX2-NEXT: vpermpd {{.*#+}} ymm0 = ymm0[2,2,2,2] 23; AVX2-NEXT: vmovaps %ymm0, (%rdi) 24; AVX2-NEXT: retq 25 %res = shufflevector <4 x double> %v, <4 x double> undef, <4 x i32> <i32 2, i32 2, i32 2, i32 2> 26 %res1 = shufflevector<4 x double> %res, <4 x double> undef, <4 x i32> <i32 2, i32 0, i32 undef, i32 undef> 27 store <4 x double> %res, ptr %p 28 ret <4 x double> %res1 29} 30 31define <8 x float> @foo8(<8 x float> %v, ptr%p) nounwind { 32; AVX2-SLOW-LABEL: foo8: 33; AVX2-SLOW: # %bb.0: 34; AVX2-SLOW-NEXT: vmovshdup {{.*#+}} ymm0 = ymm0[1,1,3,3,5,5,7,7] 35; AVX2-SLOW-NEXT: vpermpd {{.*#+}} ymm0 = ymm0[2,2,2,2] 36; AVX2-SLOW-NEXT: vmovaps %ymm0, (%rdi) 37; AVX2-SLOW-NEXT: retq 38; 39; AVX2-FAST-ALL-LABEL: foo8: 40; AVX2-FAST-ALL: # %bb.0: 41; AVX2-FAST-ALL-NEXT: vbroadcastss {{.*#+}} ymm1 = [5,5,5,5,5,5,5,5] 42; AVX2-FAST-ALL-NEXT: vpermps %ymm0, %ymm1, %ymm0 43; AVX2-FAST-ALL-NEXT: vmovaps %ymm0, (%rdi) 44; AVX2-FAST-ALL-NEXT: retq 45; 46; AVX2-FAST-PERLANE-LABEL: foo8: 47; AVX2-FAST-PERLANE: # %bb.0: 48; AVX2-FAST-PERLANE-NEXT: vmovshdup {{.*#+}} ymm0 = ymm0[1,1,3,3,5,5,7,7] 49; AVX2-FAST-PERLANE-NEXT: vpermpd {{.*#+}} ymm0 = ymm0[2,2,2,2] 50; AVX2-FAST-PERLANE-NEXT: vmovaps %ymm0, (%rdi) 51; AVX2-FAST-PERLANE-NEXT: retq 52 %res = shufflevector <8 x float> %v, <8 x float> undef, <8 x i32> <i32 5, i32 5, i32 5, i32 5, i32 5, i32 5, i32 5, i32 5> 53 %res1 = shufflevector<8 x float> %res, <8 x float> undef, <8 x i32> <i32 2, i32 0, i32 undef, i32 undef, i32 5, i32 1, i32 3, i32 7> 54 store <8 x float> %res, ptr %p 55 ret <8 x float> %res1 56} 57 58define <4 x i32> @undef_splatmask(<4 x i32> %v) nounwind { 59; AVX2-LABEL: undef_splatmask: 60; AVX2: # %bb.0: 61; AVX2-NEXT: vshufps {{.*#+}} xmm0 = xmm0[2,2,3,3] 62; AVX2-NEXT: retq 63 %res = shufflevector <4 x i32> %v, <4 x i32> undef, <4 x i32> <i32 2, i32 undef, i32 2, i32 undef> 64 %res1 = shufflevector <4 x i32> %res, <4 x i32> undef, <4 x i32> <i32 0, i32 2, i32 undef, i32 undef> 65 ret <4 x i32> %res1 66} 67 68define <4 x i32> @undef_splatmask2(<4 x i32> %v) nounwind { 69; AVX2-LABEL: undef_splatmask2: 70; AVX2: # %bb.0: 71; AVX2-NEXT: vshufps {{.*#+}} xmm0 = xmm0[2,2,3,3] 72; AVX2-NEXT: retq 73 %res = shufflevector <4 x i32> %v, <4 x i32> undef, <4 x i32> <i32 2, i32 1, i32 2, i32 undef> 74 %res1 = shufflevector <4 x i32> %res, <4 x i32> undef, <4 x i32> <i32 0, i32 2, i32 undef, i32 undef> 75 ret <4 x i32> %res1 76} 77 78define <4 x i32> @undef_splatmask3(<4 x i32> %v) nounwind { 79; AVX2-LABEL: undef_splatmask3: 80; AVX2: # %bb.0: 81; AVX2-NEXT: vshufps {{.*#+}} xmm0 = xmm0[2,2,3,3] 82; AVX2-NEXT: retq 83 %res = shufflevector <4 x i32> %v, <4 x i32> undef, <4 x i32> <i32 2, i32 undef, i32 2, i32 undef> 84 %res1 = shufflevector <4 x i32> %res, <4 x i32> undef, <4 x i32> <i32 0, i32 2, i32 undef, i32 3> 85 ret <4 x i32> %res1 86} 87 88define <4 x i32> @undef_splatmask4(<4 x i32> %v, ptr %p) nounwind { 89; AVX2-LABEL: undef_splatmask4: 90; AVX2: # %bb.0: 91; AVX2-NEXT: vshufps {{.*#+}} xmm1 = xmm0[2,2,3,3] 92; AVX2-NEXT: vshufps {{.*#+}} xmm0 = xmm0[2,3,2,3] 93; AVX2-NEXT: vmovaps %xmm0, (%rdi) 94; AVX2-NEXT: vmovaps %xmm1, %xmm0 95; AVX2-NEXT: retq 96 %res = shufflevector <4 x i32> %v, <4 x i32> undef, <4 x i32> <i32 2, i32 undef, i32 2, i32 undef> 97 %res1 = shufflevector <4 x i32> %res, <4 x i32> undef, <4 x i32> <i32 0, i32 2, i32 undef, i32 undef> 98 store <4 x i32> %res, ptr %p 99 ret <4 x i32> %res1 100} 101 102define <4 x i32> @undef_splatmask5(<4 x i32> %v, ptr %p) nounwind { 103; AVX2-LABEL: undef_splatmask5: 104; AVX2: # %bb.0: 105; AVX2-NEXT: vbroadcastss %xmm0, %xmm0 106; AVX2-NEXT: vmovaps %xmm0, (%rdi) 107; AVX2-NEXT: retq 108 %res = shufflevector <4 x i32> %v, <4 x i32> undef, <4 x i32> <i32 0, i32 undef, i32 0, i32 undef> 109 %res1 = shufflevector <4 x i32> %res, <4 x i32> undef, <4 x i32> <i32 0, i32 2, i32 undef, i32 3> 110 store <4 x i32> %res, ptr %p 111 ret <4 x i32> %res1 112} 113