1 ; RUN: llc < %s -mtriple=x86_64-linux | FileCheck %s
3 ; The Peephole optimizer should fold the load into the cmp even with debug info.
4 ; CHECK-LABEL: _ZN3Foo3batEv
6 ; CHECK: cmpq {{%[a-z]+}}, pfoo(%rip)
9 ; CHECK-NOT: movq wibble2
10 ; CHECK: cmpq {{%[a-z]+}}, wibble2(%rip)
12 ; Regenerate test with this command:
13 ; clang -emit-llvm -S -O2 -g
17 ; bool operator==(Foo &arg) { return (this == &arg); }
20 ; bool Foo::bat() { return (*this == *pfoo); }
24 ; } *wibble1, *wibble2;
26 ; void bar(Wibble *c) {
32 ; void baz() { flibble.bar(wibble1); }
34 %struct.Foo = type { i8 }
35 %struct.Wibble = type { i32 }
36 %struct.Flibble = type { i8 }
38 @pfoo = global %struct.Foo* null, align 8
39 @wibble1 = global %struct.Wibble* null, align 8
40 @wibble2 = global %struct.Wibble* null, align 8
41 @flibble = global %struct.Flibble zeroinitializer, align 1
43 ; Function Attrs: nounwind readonly uwtable
44 define zeroext i1 @_ZN3Foo3batEv(%struct.Foo* %this) #0 align 2 {
46 %0 = load %struct.Foo*, %struct.Foo** @pfoo, align 8
47 tail call void @llvm.dbg.value(metadata %struct.Foo* %0, i64 0, metadata !62, metadata !DIExpression()), !dbg !DILocation(scope: !1)
48 %cmp.i = icmp eq %struct.Foo* %0, %this
52 ; Function Attrs: nounwind uwtable
53 define void @_Z3bazv() #1 {
55 %0 = load %struct.Wibble*, %struct.Wibble** @wibble1, align 8
56 tail call void @llvm.dbg.value(metadata %struct.Flibble* undef, i64 0, metadata !65, metadata !DIExpression()), !dbg !DILocation(scope: !1)
57 %1 = load %struct.Wibble*, %struct.Wibble** @wibble2, align 8
58 %cmp.i = icmp ugt %struct.Wibble* %1, %0
59 br i1 %cmp.i, label %if.then.i, label %_ZN7Flibble3barEP6Wibble.exit
61 if.then.i: ; preds = %entry
62 store %struct.Wibble* null, %struct.Wibble** @wibble2, align 8
63 br label %_ZN7Flibble3barEP6Wibble.exit
65 _ZN7Flibble3barEP6Wibble.exit: ; preds = %entry, %if.then.i
66 %x.i = getelementptr inbounds %struct.Wibble, %struct.Wibble* %0, i64 0, i32 0
67 store i32 0, i32* %x.i, align 4
71 ; Function Attrs: nounwind readnone
72 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #2
74 attributes #0 = { nounwind readonly uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-frame-pointer-elim-non-leaf"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }
75 attributes #1 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-frame-pointer-elim-non-leaf"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }
76 attributes #2 = { nounwind readnone }
78 !1 = distinct !DISubprogram()
80 !17 = !DIDerivedType(tag: DW_TAG_reference_type, baseType: null)
81 !45 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: null)
82 !62 = !DILocalVariable(name: "arg", line: 4, arg: 2, scope: !1, type: !17)
83 !64 = !{%struct.Flibble* undef}
84 !65 = !DILocalVariable(name: "this", line: 13, arg: 1, flags: DIFlagArtificial | DIFlagObjectPointer, scope: !1, type: !45)