llvm.org GIT mirror llvm / 8dd3417
add a general coverage test for overflow intrinsics. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122185 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 9 years ago
1 changed file(s) with 220 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 ; RUN: llc < %s
1 ; Verify codegen's don't crash on overflow intrinsics.
2
3 ;; SADD
4
5 define zeroext i8 @sadd_i8(i8 signext %a, i8 signext %b) nounwind ssp {
6 entry:
7 %sadd = tail call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 %a, i8 %b)
8 %cmp = extractvalue { i8, i1 } %sadd, 1
9 %sadd.result = extractvalue { i8, i1 } %sadd, 0
10 %X = select i1 %cmp, i8 %sadd.result, i8 42
11 ret i8 %X
12 }
13
14 declare { i8, i1 } @llvm.sadd.with.overflow.i8(i8, i8) nounwind readnone
15
16 define zeroext i16 @sadd_i16(i16 signext %a, i16 signext %b) nounwind ssp {
17 entry:
18 %sadd = tail call { i16, i1 } @llvm.sadd.with.overflow.i16(i16 %a, i16 %b)
19 %cmp = extractvalue { i16, i1 } %sadd, 1
20 %sadd.result = extractvalue { i16, i1 } %sadd, 0
21 %X = select i1 %cmp, i16 %sadd.result, i16 42
22 ret i16 %X
23 }
24
25 declare { i16, i1 } @llvm.sadd.with.overflow.i16(i16, i16) nounwind readnone
26
27 define zeroext i32 @sadd_i32(i32 signext %a, i32 signext %b) nounwind ssp {
28 entry:
29 %sadd = tail call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 %a, i32 %b)
30 %cmp = extractvalue { i32, i1 } %sadd, 1
31 %sadd.result = extractvalue { i32, i1 } %sadd, 0
32 %X = select i1 %cmp, i32 %sadd.result, i32 42
33 ret i32 %X
34 }
35
36 declare { i32, i1 } @llvm.sadd.with.overflow.i32(i32, i32) nounwind readnone
37
38
39 ;; UADD
40
41 define zeroext i8 @uadd_i8(i8 signext %a, i8 signext %b) nounwind ssp {
42 entry:
43 %uadd = tail call { i8, i1 } @llvm.uadd.with.overflow.i8(i8 %a, i8 %b)
44 %cmp = extractvalue { i8, i1 } %uadd, 1
45 %uadd.result = extractvalue { i8, i1 } %uadd, 0
46 %X = select i1 %cmp, i8 %uadd.result, i8 42
47 ret i8 %X
48 }
49
50 declare { i8, i1 } @llvm.uadd.with.overflow.i8(i8, i8) nounwind readnone
51
52 define zeroext i16 @uadd_i16(i16 signext %a, i16 signext %b) nounwind ssp {
53 entry:
54 %uadd = tail call { i16, i1 } @llvm.uadd.with.overflow.i16(i16 %a, i16 %b)
55 %cmp = extractvalue { i16, i1 } %uadd, 1
56 %uadd.result = extractvalue { i16, i1 } %uadd, 0
57 %X = select i1 %cmp, i16 %uadd.result, i16 42
58 ret i16 %X
59 }
60
61 declare { i16, i1 } @llvm.uadd.with.overflow.i16(i16, i16) nounwind readnone
62
63 define zeroext i32 @uadd_i32(i32 signext %a, i32 signext %b) nounwind ssp {
64 entry:
65 %uadd = tail call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 %a, i32 %b)
66 %cmp = extractvalue { i32, i1 } %uadd, 1
67 %uadd.result = extractvalue { i32, i1 } %uadd, 0
68 %X = select i1 %cmp, i32 %uadd.result, i32 42
69 ret i32 %X
70 }
71
72 declare { i32, i1 } @llvm.uadd.with.overflow.i32(i32, i32) nounwind readnone
73
74
75
76 ;; ssub
77
78 define zeroext i8 @ssub_i8(i8 signext %a, i8 signext %b) nounwind ssp {
79 entry:
80 %ssub = tail call { i8, i1 } @llvm.ssub.with.overflow.i8(i8 %a, i8 %b)
81 %cmp = extractvalue { i8, i1 } %ssub, 1
82 %ssub.result = extractvalue { i8, i1 } %ssub, 0
83 %X = select i1 %cmp, i8 %ssub.result, i8 42
84 ret i8 %X
85 }
86
87 declare { i8, i1 } @llvm.ssub.with.overflow.i8(i8, i8) nounwind readnone
88
89 define zeroext i16 @ssub_i16(i16 signext %a, i16 signext %b) nounwind ssp {
90 entry:
91 %ssub = tail call { i16, i1 } @llvm.ssub.with.overflow.i16(i16 %a, i16 %b)
92 %cmp = extractvalue { i16, i1 } %ssub, 1
93 %ssub.result = extractvalue { i16, i1 } %ssub, 0
94 %X = select i1 %cmp, i16 %ssub.result, i16 42
95 ret i16 %X
96 }
97
98 declare { i16, i1 } @llvm.ssub.with.overflow.i16(i16, i16) nounwind readnone
99
100 define zeroext i32 @ssub_i32(i32 signext %a, i32 signext %b) nounwind ssp {
101 entry:
102 %ssub = tail call { i32, i1 } @llvm.ssub.with.overflow.i32(i32 %a, i32 %b)
103 %cmp = extractvalue { i32, i1 } %ssub, 1
104 %ssub.result = extractvalue { i32, i1 } %ssub, 0
105 %X = select i1 %cmp, i32 %ssub.result, i32 42
106 ret i32 %X
107 }
108
109 declare { i32, i1 } @llvm.ssub.with.overflow.i32(i32, i32) nounwind readnone
110
111
112 ;; usub
113
114 define zeroext i8 @usub_i8(i8 signext %a, i8 signext %b) nounwind ssp {
115 entry:
116 %usub = tail call { i8, i1 } @llvm.usub.with.overflow.i8(i8 %a, i8 %b)
117 %cmp = extractvalue { i8, i1 } %usub, 1
118 %usub.result = extractvalue { i8, i1 } %usub, 0
119 %X = select i1 %cmp, i8 %usub.result, i8 42
120 ret i8 %X
121 }
122
123 declare { i8, i1 } @llvm.usub.with.overflow.i8(i8, i8) nounwind readnone
124
125 define zeroext i16 @usub_i16(i16 signext %a, i16 signext %b) nounwind ssp {
126 entry:
127 %usub = tail call { i16, i1 } @llvm.usub.with.overflow.i16(i16 %a, i16 %b)
128 %cmp = extractvalue { i16, i1 } %usub, 1
129 %usub.result = extractvalue { i16, i1 } %usub, 0
130 %X = select i1 %cmp, i16 %usub.result, i16 42
131 ret i16 %X
132 }
133
134 declare { i16, i1 } @llvm.usub.with.overflow.i16(i16, i16) nounwind readnone
135
136 define zeroext i32 @usub_i32(i32 signext %a, i32 signext %b) nounwind ssp {
137 entry:
138 %usub = tail call { i32, i1 } @llvm.usub.with.overflow.i32(i32 %a, i32 %b)
139 %cmp = extractvalue { i32, i1 } %usub, 1
140 %usub.result = extractvalue { i32, i1 } %usub, 0
141 %X = select i1 %cmp, i32 %usub.result, i32 42
142 ret i32 %X
143 }
144
145 declare { i32, i1 } @llvm.usub.with.overflow.i32(i32, i32) nounwind readnone
146
147
148
149 ;; smul
150
151 define zeroext i8 @smul_i8(i8 signext %a, i8 signext %b) nounwind ssp {
152 entry:
153 %smul = tail call { i8, i1 } @llvm.smul.with.overflow.i8(i8 %a, i8 %b)
154 %cmp = extractvalue { i8, i1 } %smul, 1
155 %smul.result = extractvalue { i8, i1 } %smul, 0
156 %X = select i1 %cmp, i8 %smul.result, i8 42
157 ret i8 %X
158 }
159
160 declare { i8, i1 } @llvm.smul.with.overflow.i8(i8, i8) nounwind readnone
161
162 define zeroext i16 @smul_i16(i16 signext %a, i16 signext %b) nounwind ssp {
163 entry:
164 %smul = tail call { i16, i1 } @llvm.smul.with.overflow.i16(i16 %a, i16 %b)
165 %cmp = extractvalue { i16, i1 } %smul, 1
166 %smul.result = extractvalue { i16, i1 } %smul, 0
167 %X = select i1 %cmp, i16 %smul.result, i16 42
168 ret i16 %X
169 }
170
171 declare { i16, i1 } @llvm.smul.with.overflow.i16(i16, i16) nounwind readnone
172
173 define zeroext i32 @smul_i32(i32 signext %a, i32 signext %b) nounwind ssp {
174 entry:
175 %smul = tail call { i32, i1 } @llvm.smul.with.overflow.i32(i32 %a, i32 %b)
176 %cmp = extractvalue { i32, i1 } %smul, 1
177 %smul.result = extractvalue { i32, i1 } %smul, 0
178 %X = select i1 %cmp, i32 %smul.result, i32 42
179 ret i32 %X
180 }
181
182 declare { i32, i1 } @llvm.smul.with.overflow.i32(i32, i32) nounwind readnone
183
184
185 ;; umul
186
187 define zeroext i8 @umul_i8(i8 signext %a, i8 signext %b) nounwind ssp {
188 entry:
189 %umul = tail call { i8, i1 } @llvm.umul.with.overflow.i8(i8 %a, i8 %b)
190 %cmp = extractvalue { i8, i1 } %umul, 1
191 %umul.result = extractvalue { i8, i1 } %umul, 0
192 %X = select i1 %cmp, i8 %umul.result, i8 42
193 ret i8 %X
194 }
195
196 declare { i8, i1 } @llvm.umul.with.overflow.i8(i8, i8) nounwind readnone
197
198 define zeroext i16 @umul_i16(i16 signext %a, i16 signext %b) nounwind ssp {
199 entry:
200 %umul = tail call { i16, i1 } @llvm.umul.with.overflow.i16(i16 %a, i16 %b)
201 %cmp = extractvalue { i16, i1 } %umul, 1
202 %umul.result = extractvalue { i16, i1 } %umul, 0
203 %X = select i1 %cmp, i16 %umul.result, i16 42
204 ret i16 %X
205 }
206
207 declare { i16, i1 } @llvm.umul.with.overflow.i16(i16, i16) nounwind readnone
208
209 define zeroext i32 @umul_i32(i32 signext %a, i32 signext %b) nounwind ssp {
210 entry:
211 %umul = tail call { i32, i1 } @llvm.umul.with.overflow.i32(i32 %a, i32 %b)
212 %cmp = extractvalue { i32, i1 } %umul, 1
213 %umul.result = extractvalue { i32, i1 } %umul, 0
214 %X = select i1 %cmp, i32 %umul.result, i32 42
215 ret i32 %X
216 }
217
218 declare { i32, i1 } @llvm.umul.with.overflow.i32(i32, i32) nounwind readnone
219