1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=i386-unknown-linux-gnu -mattr=-slow-incdec < %s | FileCheck -check-prefix=CHECK -check-prefix=INCDEC %s
3 ; RUN: llc -mtriple=i386-unknown-linux-gnu -mattr=+slow-incdec < %s | FileCheck -check-prefix=CHECK -check-prefix=ADD %s
5 define i32 @inc(i32 %x) {
8 ; INCDEC-NEXT: movl {{[0-9]+}}(%esp), %eax
9 ; INCDEC-NEXT: incl %eax
14 ; ADD-NEXT: movl {{[0-9]+}}(%esp), %eax
15 ; ADD-NEXT: addl $1, %eax
21 define i32 @dec(i32 %x) {
24 ; INCDEC-NEXT: movl {{[0-9]+}}(%esp), %eax
25 ; INCDEC-NEXT: decl %eax
30 ; ADD-NEXT: movl {{[0-9]+}}(%esp), %eax
31 ; ADD-NEXT: addl $-1, %eax
37 define i32 @inc_size(i32 %x) optsize {
38 ; CHECK-LABEL: inc_size:
40 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax
41 ; CHECK-NEXT: incl %eax
47 define i32 @dec_size(i32 %x) optsize {
48 ; CHECK-LABEL: dec_size:
50 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax
51 ; CHECK-NEXT: decl %eax
57 define i32 @inc_pgso(i32 %x) !prof !14 {
58 ; CHECK-LABEL: inc_pgso:
60 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax
61 ; CHECK-NEXT: incl %eax
67 define i32 @dec_pgso(i32 %x) !prof !14 {
68 ; CHECK-LABEL: dec_pgso:
70 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax
71 ; CHECK-NEXT: decl %eax
77 declare {i32, i1} @llvm.uadd.with.overflow.i32(i32, i32)
78 declare void @other(ptr ) nounwind;
80 define void @cond_ae_to_cond_ne(ptr %p) nounwind {
81 ; INCDEC-LABEL: cond_ae_to_cond_ne:
82 ; INCDEC: # %bb.0: # %entry
83 ; INCDEC-NEXT: movl {{[0-9]+}}(%esp), %eax
84 ; INCDEC-NEXT: incl (%eax)
85 ; INCDEC-NEXT: je other@PLT # TAILCALL
86 ; INCDEC-NEXT: # %bb.1: # %return
89 ; ADD-LABEL: cond_ae_to_cond_ne:
90 ; ADD: # %bb.0: # %entry
91 ; ADD-NEXT: movl {{[0-9]+}}(%esp), %eax
92 ; ADD-NEXT: addl $1, (%eax)
93 ; ADD-NEXT: je other@PLT # TAILCALL
94 ; ADD-NEXT: # %bb.1: # %return
97 %t0 = load i32, ptr %p, align 8
98 %add_ov = call {i32, i1} @llvm.uadd.with.overflow.i32(i32 %t0, i32 1)
99 %inc = extractvalue { i32, i1 } %add_ov, 0
100 store i32 %inc, ptr %p, align 8
101 %ov = extractvalue { i32, i1 } %add_ov, 1
102 br i1 %ov, label %if.end4, label %return
105 tail call void @other(ptr %p) nounwind
112 @a = common global i8 0, align 1
113 @d = common global i8 0, align 1
115 declare void @external_a()
116 declare void @external_b()
117 declare {i8, i1} @llvm.uadd.with.overflow.i8(i8, i8)
119 define void @test_tail_call(ptr %ptr) nounwind {
120 ; INCDEC-LABEL: test_tail_call:
121 ; INCDEC: # %bb.0: # %entry
122 ; INCDEC-NEXT: movl {{[0-9]+}}(%esp), %eax
123 ; INCDEC-NEXT: incl (%eax)
124 ; INCDEC-NEXT: setne %al
125 ; INCDEC-NEXT: incb a
126 ; INCDEC-NEXT: sete d
127 ; INCDEC-NEXT: testb %al, %al
128 ; INCDEC-NEXT: jne external_b@PLT # TAILCALL
129 ; INCDEC-NEXT: # %bb.1: # %then
130 ; INCDEC-NEXT: jmp external_a@PLT # TAILCALL
132 ; ADD-LABEL: test_tail_call:
133 ; ADD: # %bb.0: # %entry
134 ; ADD-NEXT: movl {{[0-9]+}}(%esp), %eax
135 ; ADD-NEXT: addl $1, (%eax)
136 ; ADD-NEXT: setne %al
137 ; ADD-NEXT: addb $1, a
139 ; ADD-NEXT: testb %al, %al
140 ; ADD-NEXT: jne external_b@PLT # TAILCALL
141 ; ADD-NEXT: # %bb.1: # %then
142 ; ADD-NEXT: jmp external_a@PLT # TAILCALL
144 %val = load i32, ptr %ptr
145 %add_ov = call {i32, i1} @llvm.uadd.with.overflow.i32(i32 %val, i32 1)
146 %inc = extractvalue { i32, i1 } %add_ov, 0
147 store i32 %inc, ptr %ptr
148 %cmp = extractvalue { i32, i1 } %add_ov, 1
149 %aval = load volatile i8, ptr @a
150 %add_ov2 = call {i8, i1} @llvm.uadd.with.overflow.i8(i8 %aval, i8 1)
151 %inc2 = extractvalue { i8, i1 } %add_ov2, 0
152 store volatile i8 %inc2, ptr @a
153 %cmp2 = extractvalue { i8, i1 } %add_ov2, 1
154 %conv5 = zext i1 %cmp2 to i8
155 store i8 %conv5, ptr @d
156 br i1 %cmp, label %then, label %else
159 tail call void @external_a()
163 tail call void @external_b()
167 !llvm.module.flags = !{!0}
168 !0 = !{i32 1, !"ProfileSummary", !1}
169 !1 = !{!2, !3, !4, !5, !6, !7, !8, !9}
170 !2 = !{!"ProfileFormat", !"InstrProf"}
171 !3 = !{!"TotalCount", i64 10000}
172 !4 = !{!"MaxCount", i64 10}
173 !5 = !{!"MaxInternalCount", i64 1}
174 !6 = !{!"MaxFunctionCount", i64 1000}
175 !7 = !{!"NumCounts", i64 3}
176 !8 = !{!"NumFunctions", i64 3}
177 !9 = !{!"DetailedSummary", !10}
178 !10 = !{!11, !12, !13}
179 !11 = !{i32 10000, i64 100, i32 1}
180 !12 = !{i32 999000, i64 100, i32 1}
181 !13 = !{i32 999999, i64 1, i32 2}
182 !14 = !{!"function_entry_count", i64 0}