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 declare {i32, i1} @llvm.uadd.with.overflow.i32(i32, i32)
58 declare void @other(i32* ) nounwind;
60 define void @cond_ae_to_cond_ne(i32* %p) nounwind {
61 ; INCDEC-LABEL: cond_ae_to_cond_ne:
62 ; INCDEC: # %bb.0: # %entry
63 ; INCDEC-NEXT: movl {{[0-9]+}}(%esp), %eax
64 ; INCDEC-NEXT: incl (%eax)
65 ; INCDEC-NEXT: jne .LBB4_1
66 ; INCDEC-NEXT: # %bb.2: # %if.end4
67 ; INCDEC-NEXT: jmp other # TAILCALL
68 ; INCDEC-NEXT: .LBB4_1: # %return
71 ; ADD-LABEL: cond_ae_to_cond_ne:
72 ; ADD: # %bb.0: # %entry
73 ; ADD-NEXT: movl {{[0-9]+}}(%esp), %eax
74 ; ADD-NEXT: addl $1, (%eax)
75 ; ADD-NEXT: jne .LBB4_1
76 ; ADD-NEXT: # %bb.2: # %if.end4
77 ; ADD-NEXT: jmp other # TAILCALL
78 ; ADD-NEXT: .LBB4_1: # %return
81 %t0 = load i32, i32* %p, align 8
82 %add_ov = call {i32, i1} @llvm.uadd.with.overflow.i32(i32 %t0, i32 1)
83 %inc = extractvalue { i32, i1 } %add_ov, 0
84 store i32 %inc, i32* %p, align 8
85 %ov = extractvalue { i32, i1 } %add_ov, 1
86 br i1 %ov, label %if.end4, label %return
89 tail call void @other(i32* %p) nounwind
96 @a = common global i8 0, align 1
97 @d = common global i8 0, align 1
99 declare void @external_a()
100 declare void @external_b()
101 declare {i8, i1} @llvm.uadd.with.overflow.i8(i8, i8)
103 define void @test_tail_call(i32* %ptr) nounwind {
104 ; INCDEC-LABEL: test_tail_call:
105 ; INCDEC: # %bb.0: # %entry
106 ; INCDEC-NEXT: movl {{[0-9]+}}(%esp), %eax
107 ; INCDEC-NEXT: incl (%eax)
108 ; INCDEC-NEXT: setne %al
109 ; INCDEC-NEXT: incb a
110 ; INCDEC-NEXT: sete d
111 ; INCDEC-NEXT: testb %al, %al
112 ; INCDEC-NEXT: jne .LBB5_2
113 ; INCDEC-NEXT: # %bb.1: # %then
114 ; INCDEC-NEXT: jmp external_a # TAILCALL
115 ; INCDEC-NEXT: .LBB5_2: # %else
116 ; INCDEC-NEXT: jmp external_b # TAILCALL
118 ; ADD-LABEL: test_tail_call:
119 ; ADD: # %bb.0: # %entry
120 ; ADD-NEXT: movl {{[0-9]+}}(%esp), %eax
121 ; ADD-NEXT: addl $1, (%eax)
122 ; ADD-NEXT: setne %al
123 ; ADD-NEXT: addb $1, a
125 ; ADD-NEXT: testb %al, %al
126 ; ADD-NEXT: jne .LBB5_2
127 ; ADD-NEXT: # %bb.1: # %then
128 ; ADD-NEXT: jmp external_a # TAILCALL
129 ; ADD-NEXT: .LBB5_2: # %else
130 ; ADD-NEXT: jmp external_b # TAILCALL
132 %val = load i32, i32* %ptr
133 %add_ov = call {i32, i1} @llvm.uadd.with.overflow.i32(i32 %val, i32 1)
134 %inc = extractvalue { i32, i1 } %add_ov, 0
135 store i32 %inc, i32* %ptr
136 %cmp = extractvalue { i32, i1 } %add_ov, 1
137 %aval = load volatile i8, i8* @a
138 %add_ov2 = call {i8, i1} @llvm.uadd.with.overflow.i8(i8 %aval, i8 1)
139 %inc2 = extractvalue { i8, i1 } %add_ov2, 0
140 store volatile i8 %inc2, i8* @a
141 %cmp2 = extractvalue { i8, i1 } %add_ov2, 1
142 %conv5 = zext i1 %cmp2 to i8
143 store i8 %conv5, i8* @d
144 br i1 %cmp, label %then, label %else
147 tail call void @external_a()
151 tail call void @external_b()