xref: /llvm-project/llvm/test/CodeGen/X86/peephole-fold-movsd.ll (revision 4318b033bddc64d5654f3e368fddde859ff4d02e)
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(ptr)
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  call void @foo3(ptr %1) #2
29  %2 = load double, ptr %1, align 16
30  %p3 = getelementptr inbounds %struct.S1, ptr %1, i64 0, i32 1
31  %3 = load double, ptr %p3, align 8
32  %4 = insertelement <2 x double> undef, double %2, i32 0
33  %5 = insertelement <2 x double> %4, double 0.000000e+00, i32 1
34  %6 = insertelement <2 x double> undef, double %3, i32 1
35  %7 = insertelement <2 x double> %6, double 1.000000e+00, i32 0
36  %8 = fadd <2 x double> %5, %7
37  store <2 x double> %8, ptr @g, align 16
38  ret void
39}
40