1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2; RUN: llc < %s -mtriple=i686-unknown-linux-gnu -mattr=+sse2,-sse4.1 | FileCheck %s --check-prefix=X32 3; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -mattr=+sse2,-sse4.1 | FileCheck %s --check-prefix=X64 4 5define void @test1(<4 x float>* %F, float* %f) nounwind { 6; X32-LABEL: test1: 7; X32: # %bb.0: # %entry 8; X32-NEXT: movl {{[0-9]+}}(%esp), %eax 9; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx 10; X32-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero 11; X32-NEXT: addss %xmm0, %xmm0 12; X32-NEXT: movss %xmm0, (%eax) 13; X32-NEXT: retl 14; 15; X64-LABEL: test1: 16; X64: # %bb.0: # %entry 17; X64-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero 18; X64-NEXT: addss %xmm0, %xmm0 19; X64-NEXT: movss %xmm0, (%rsi) 20; X64-NEXT: retq 21entry: 22 %tmp = load <4 x float>, <4 x float>* %F 23 %tmp7 = fadd <4 x float> %tmp, %tmp 24 %tmp2 = extractelement <4 x float> %tmp7, i32 0 25 store float %tmp2, float* %f 26 ret void 27} 28 29define float @test2(<4 x float>* %F, float* %f) nounwind { 30; X32-LABEL: test2: 31; X32: # %bb.0: # %entry 32; X32-NEXT: pushl %eax 33; X32-NEXT: movl {{[0-9]+}}(%esp), %eax 34; X32-NEXT: movaps (%eax), %xmm0 35; X32-NEXT: addps %xmm0, %xmm0 36; X32-NEXT: movhlps {{.*#+}} xmm0 = xmm0[1,1] 37; X32-NEXT: movss %xmm0, (%esp) 38; X32-NEXT: flds (%esp) 39; X32-NEXT: popl %eax 40; X32-NEXT: retl 41; 42; X64-LABEL: test2: 43; X64: # %bb.0: # %entry 44; X64-NEXT: movaps (%rdi), %xmm0 45; X64-NEXT: addps %xmm0, %xmm0 46; X64-NEXT: movhlps {{.*#+}} xmm0 = xmm0[1,1] 47; X64-NEXT: retq 48entry: 49 %tmp = load <4 x float>, <4 x float>* %F 50 %tmp7 = fadd <4 x float> %tmp, %tmp 51 %tmp2 = extractelement <4 x float> %tmp7, i32 2 52 ret float %tmp2 53} 54 55define void @test3(float* %R, <4 x float>* %P1) nounwind { 56; X32-LABEL: test3: 57; X32: # %bb.0: # %entry 58; X32-NEXT: movl {{[0-9]+}}(%esp), %eax 59; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx 60; X32-NEXT: movaps (%ecx), %xmm0 61; X32-NEXT: shufps {{.*#+}} xmm0 = xmm0[3,3,3,3] 62; X32-NEXT: movss %xmm0, (%eax) 63; X32-NEXT: retl 64; 65; X64-LABEL: test3: 66; X64: # %bb.0: # %entry 67; X64-NEXT: movaps (%rsi), %xmm0 68; X64-NEXT: shufps {{.*#+}} xmm0 = xmm0[3,3,3,3] 69; X64-NEXT: movss %xmm0, (%rdi) 70; X64-NEXT: retq 71entry: 72 %X = load <4 x float>, <4 x float>* %P1 73 %tmp = extractelement <4 x float> %X, i32 3 74 store float %tmp, float* %R 75 ret void 76} 77 78define double @test4(double %A) nounwind { 79; X32-LABEL: test4: 80; X32: # %bb.0: # %entry 81; X32-NEXT: subl $12, %esp 82; X32-NEXT: calll foo 83; X32-NEXT: unpckhpd {{.*#+}} xmm0 = xmm0[1,1] 84; X32-NEXT: addsd {{[0-9]+}}(%esp), %xmm0 85; X32-NEXT: movsd %xmm0, (%esp) 86; X32-NEXT: fldl (%esp) 87; X32-NEXT: addl $12, %esp 88; X32-NEXT: retl 89; 90; X64-LABEL: test4: 91; X64: # %bb.0: # %entry 92; X64-NEXT: pushq %rax 93; X64-NEXT: movsd %xmm0, (%rsp) # 8-byte Spill 94; X64-NEXT: callq foo 95; X64-NEXT: unpckhpd {{.*#+}} xmm0 = xmm0[1,1] 96; X64-NEXT: addsd (%rsp), %xmm0 # 8-byte Folded Reload 97; X64-NEXT: popq %rax 98; X64-NEXT: retq 99entry: 100 %tmp1 = call <2 x double> @foo( ) 101 %tmp2 = extractelement <2 x double> %tmp1, i32 1 102 %tmp3 = fadd double %tmp2, %A 103 ret double %tmp3 104} 105declare <2 x double> @foo() 106 107; OSS-Fuzz #15662 108; https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=15662 109define <4 x i32> @ossfuzz15662(<4 x i32*>* %in) { 110; X32-LABEL: ossfuzz15662: 111; X32: # %bb.0: 112; X32-NEXT: xorps %xmm0, %xmm0 113; X32-NEXT: retl 114; 115; X64-LABEL: ossfuzz15662: 116; X64: # %bb.0: 117; X64-NEXT: xorps %xmm0, %xmm0 118; X64-NEXT: retq 119 %C10 = icmp ule i1 false, false 120 %C3 = icmp ule i1 true, undef 121 %B = sdiv i1 %C10, %C3 122 %I = insertelement <4 x i32> zeroinitializer, i32 0, i1 %B 123 store <4 x i32> %I, <4 x i32>* undef 124 ret <4 x i32> zeroinitializer 125} 126