1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -mattr=sse -enable-unsafe-fp-math < %s | FileCheck %s
4 ; The debug info in this test case was causing a crash because machine trace metrics
5 ; did not correctly ignore debug instructions. The check lines ensure that the
6 ; machine-combiner pass has run, reassociated the add operands, and therefore
7 ; used machine trace metrics.
9 define void @PR24199(i32 %a0) {
10 ; CHECK-LABEL: PR24199:
11 ; CHECK: # %bb.0: # %entry
12 ; CHECK-NEXT: pushq %rbx
13 ; CHECK-NEXT: .cfi_def_cfa_offset 16
14 ; CHECK-NEXT: subq $16, %rsp
15 ; CHECK-NEXT: .cfi_def_cfa_offset 32
16 ; CHECK-NEXT: .cfi_offset %rbx, -16
17 ; CHECK-NEXT: movl %edi, %ebx
18 ; CHECK-NEXT: xorl %eax, %eax
19 ; CHECK-NEXT: testb %al, %al
20 ; CHECK-NEXT: je .LBB0_2
21 ; CHECK-NEXT: # %bb.1:
22 ; CHECK-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
23 ; CHECK-NEXT: jmp .LBB0_3
24 ; CHECK-NEXT: .LBB0_2: # %if.then
25 ; CHECK-NEXT: xorps %xmm0, %xmm0
26 ; CHECK-NEXT: .LBB0_3: # %if.end
27 ; CHECK-NEXT: movss %xmm0, {{[-0-9]+}}(%r{{[sb]}}p) # 4-byte Spill
28 ; CHECK-NEXT: callq foo
29 ; CHECK-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
30 ; CHECK-NEXT: movss {{[-0-9]+}}(%r{{[sb]}}p), %xmm2 # 4-byte Reload
31 ; CHECK-NEXT: # xmm2 = mem[0],zero,zero,zero
32 ; CHECK-NEXT: mulss %xmm0, %xmm2
33 ; CHECK-NEXT: movss {{.*#+}} xmm1 = mem[0],zero,zero,zero
34 ; CHECK-NEXT: addss %xmm1, %xmm0
35 ; CHECK-NEXT: addss %xmm2, %xmm0
36 ; CHECK-NEXT: movss %xmm0, (%rax)
37 ; CHECK-NEXT: testl %ebx, %ebx
38 ; CHECK-NEXT: jne .LBB0_5
39 ; CHECK-NEXT: # %bb.4: # %if.end
40 ; CHECK-NEXT: xorps %xmm1, %xmm1
41 ; CHECK-NEXT: .LBB0_5: # %if.end
42 ; CHECK-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
43 ; CHECK-NEXT: addss %xmm0, %xmm0
44 ; CHECK-NEXT: addss %xmm1, %xmm0
45 ; CHECK-NEXT: callq bar
46 ; CHECK-NEXT: addq $16, %rsp
47 ; CHECK-NEXT: .cfi_def_cfa_offset 16
48 ; CHECK-NEXT: popq %rbx
49 ; CHECK-NEXT: .cfi_def_cfa_offset 8
53 %i = alloca %struct.A, align 8
54 %tobool = icmp ne i32 %a0, 0
55 br i1 undef, label %if.end, label %if.then
61 %h = phi float [ 0.0, %if.then ], [ 4.0, %entry ]
62 call void @foo(%struct.A* nonnull undef)
63 tail call void @llvm.dbg.value(metadata %struct.A* undef, i64 0, metadata !5, metadata !4), !dbg !6
64 tail call void @llvm.dbg.value(metadata float %h, i64 0, metadata !5, metadata !4), !dbg !6
65 %n0 = load float, float* undef, align 4
66 %mul = fmul fast float %n0, %h
67 %add = fadd fast float %mul, 1.0
68 tail call void @llvm.dbg.value(metadata %struct.A* undef, i64 0, metadata !5, metadata !4), !dbg !6
69 tail call void @llvm.dbg.value(metadata float %add, i64 0, metadata !5, metadata !4), !dbg !6
70 %add.i = fadd fast float %add, %n0
71 store float %add.i, float* undef, align 4
72 %n1 = bitcast %struct.A* %i to i8*
73 call void @llvm.lifetime.start.p0i8(i64 16, i8* %n1)
74 %n2 = load <2 x float>, <2 x float>* undef, align 8
75 %conv = uitofp i1 %tobool to float
76 %bitcast = extractelement <2 x float> %n2, i32 0
77 %factor = fmul fast float %bitcast, 2.0
78 %add3 = fadd fast float %factor, %conv
79 call void @bar(float %add3)
83 %struct.A = type { float, float }
85 declare void @bar(float)
86 declare void @foo(%struct.A*)
87 declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture)
88 declare void @llvm.dbg.value(metadata, i64, metadata, metadata)
91 !llvm.module.flags = !{!2}
93 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
94 !1 = !DIFile(filename: "24199.cpp", directory: "/bin")
95 !2 = !{i32 2, !"Debug Info Version", i32 3}
96 !3 = distinct !DISubprogram(linkageName: "foo", file: !1, line: 18, isLocal: false, isDefinition: true, scopeLine: 18, unit: !0)
98 !5 = !DILocalVariable(name: "this", arg: 1, scope: !3, flags: DIFlagArtificial | DIFlagObjectPointer)
99 !6 = !DILocation(line: 0, scope: !3)