1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -mtriple=x86_64-pc-linux < %s | FileCheck %s
3;
4; Check that x86's peephole optimization doesn't fold a 64-bit load (movsd) into
5; addpd.
6; rdar://problem/18236850
7
8%struct.S1 = type { double, double }
9
10@g = common dso_local global %struct.S1 zeroinitializer, align 8
11
12declare void @foo3(%struct.S1*)
13
14define dso_local void @foo1(double %a.coerce0, double %a.coerce1, double %b.coerce0, double %b.coerce1) nounwind {
15; CHECK-LABEL: foo1:
16; CHECK:       # %bb.0:
17; CHECK-NEXT:    subq $24, %rsp
18; CHECK-NEXT:    movq %rsp, %rdi
19; CHECK-NEXT:    callq foo3@PLT
20; CHECK-NEXT:    movsd {{.*#+}} xmm0 = mem[0],zero
21; CHECK-NEXT:    movapd {{.*#+}} xmm1 = <1.0E+0,u>
22; CHECK-NEXT:    movhpd {{.*#+}} xmm1 = xmm1[0],mem[0]
23; CHECK-NEXT:    addpd %xmm0, %xmm1
24; CHECK-NEXT:    movapd %xmm1, g(%rip)
25; CHECK-NEXT:    addq $24, %rsp
26; CHECK-NEXT:    retq
27  %1 = alloca <2 x double>, align 16
28  %tmpcast = bitcast <2 x double>* %1 to %struct.S1*
29  call void @foo3(%struct.S1* %tmpcast) #2
30  %p2 = getelementptr inbounds %struct.S1, %struct.S1* %tmpcast, i64 0, i32 0
31  %2 = load double, double* %p2, align 16
32  %p3 = getelementptr inbounds %struct.S1, %struct.S1* %tmpcast, i64 0, i32 1
33  %3 = load double, double* %p3, align 8
34  %4 = insertelement <2 x double> undef, double %2, i32 0
35  %5 = insertelement <2 x double> %4, double 0.000000e+00, i32 1
36  %6 = insertelement <2 x double> undef, double %3, i32 1
37  %7 = insertelement <2 x double> %6, double 1.000000e+00, i32 0
38  %8 = fadd <2 x double> %5, %7
39  store <2 x double> %8, <2 x double>* bitcast (%struct.S1* @g to <2 x double>*), align 16
40  ret void
41}
42