@@ -25,9 +25,9 @@ define i8 @unsigned_sat_constant_i8_using_cmp_sum(i8 %x) {
2525; CHECK-LABEL: unsigned_sat_constant_i8_using_cmp_sum:
2626; CHECK: // %bb.0:
2727; CHECK-NEXT: and w8, w0, #0xff
28- ; CHECK-NEXT: add w8, w8 , #42
29- ; CHECK-NEXT: tst w8, #0x100
30- ; CHECK-NEXT: csinv w0, w8 , wzr, eq
28+ ; CHECK-NEXT: add w9, w0 , #42
29+ ; CHECK-NEXT: cmp w8, w9, uxtb
30+ ; CHECK-NEXT: csinv w0, w9 , wzr, ls
3131; CHECK-NEXT: ret
3232 %a = add i8 %x , 42
3333 %c = icmp ugt i8 %x , %a
@@ -68,9 +68,9 @@ define i16 @unsigned_sat_constant_i16_using_cmp_sum(i16 %x) {
6868; CHECK-LABEL: unsigned_sat_constant_i16_using_cmp_sum:
6969; CHECK: // %bb.0:
7070; CHECK-NEXT: and w8, w0, #0xffff
71- ; CHECK-NEXT: add w8, w8 , #42
72- ; CHECK-NEXT: tst w8, #0x10000
73- ; CHECK-NEXT: csinv w0, w8 , wzr, eq
71+ ; CHECK-NEXT: add w9, w0 , #42
72+ ; CHECK-NEXT: cmp w8, w9, uxth
73+ ; CHECK-NEXT: csinv w0, w9 , wzr, ls
7474; CHECK-NEXT: ret
7575 %a = add i16 %x , 42
7676 %c = icmp ugt i16 %x , %a
@@ -188,9 +188,9 @@ define i8 @unsigned_sat_variable_i8_using_cmp_sum(i8 %x, i8 %y) {
188188; CHECK-LABEL: unsigned_sat_variable_i8_using_cmp_sum:
189189; CHECK: // %bb.0:
190190; CHECK-NEXT: and w8, w0, #0xff
191- ; CHECK-NEXT: add w8, w8 , w1, uxtb
192- ; CHECK-NEXT: tst w8, #0x100
193- ; CHECK-NEXT: csinv w0, w8 , wzr, eq
191+ ; CHECK-NEXT: add w9, w0 , w1
192+ ; CHECK-NEXT: cmp w8, w9, uxtb
193+ ; CHECK-NEXT: csinv w0, w9 , wzr, ls
194194; CHECK-NEXT: ret
195195 %a = add i8 %x , %y
196196 %c = icmp ugt i8 %x , %a
@@ -201,11 +201,11 @@ define i8 @unsigned_sat_variable_i8_using_cmp_sum(i8 %x, i8 %y) {
201201define i8 @unsigned_sat_variable_i8_using_cmp_notval (i8 %x , i8 %y ) {
202202; CHECK-LABEL: unsigned_sat_variable_i8_using_cmp_notval:
203203; CHECK: // %bb.0:
204- ; CHECK-NEXT: and w8, w1 , #0xff
205- ; CHECK-NEXT: add w9, w0 , w1
206- ; CHECK-NEXT: add w8, w8, w0, uxtb
207- ; CHECK-NEXT: tst w8, #0x100
208- ; CHECK-NEXT: csinv w0, w9 , wzr, eq
204+ ; CHECK-NEXT: and w8, w0 , #0xff
205+ ; CHECK-NEXT: mvn w9, w1
206+ ; CHECK-NEXT: add w10, w0, w1
207+ ; CHECK-NEXT: cmp w8, w9, uxtb
208+ ; CHECK-NEXT: csinv w0, w10 , wzr, ls
209209; CHECK-NEXT: ret
210210 %noty = xor i8 %y , -1
211211 %a = add i8 %x , %y
@@ -234,9 +234,9 @@ define i16 @unsigned_sat_variable_i16_using_cmp_sum(i16 %x, i16 %y) {
234234; CHECK-LABEL: unsigned_sat_variable_i16_using_cmp_sum:
235235; CHECK: // %bb.0:
236236; CHECK-NEXT: and w8, w0, #0xffff
237- ; CHECK-NEXT: add w8, w8 , w1, uxth
238- ; CHECK-NEXT: tst w8, #0x10000
239- ; CHECK-NEXT: csinv w0, w8 , wzr, eq
237+ ; CHECK-NEXT: add w9, w0 , w1
238+ ; CHECK-NEXT: cmp w8, w9, uxth
239+ ; CHECK-NEXT: csinv w0, w9 , wzr, ls
240240; CHECK-NEXT: ret
241241 %a = add i16 %x , %y
242242 %c = icmp ugt i16 %x , %a
@@ -247,11 +247,11 @@ define i16 @unsigned_sat_variable_i16_using_cmp_sum(i16 %x, i16 %y) {
247247define i16 @unsigned_sat_variable_i16_using_cmp_notval (i16 %x , i16 %y ) {
248248; CHECK-LABEL: unsigned_sat_variable_i16_using_cmp_notval:
249249; CHECK: // %bb.0:
250- ; CHECK-NEXT: and w8, w1 , #0xffff
251- ; CHECK-NEXT: add w9, w0 , w1
252- ; CHECK-NEXT: add w8, w8, w0, uxth
253- ; CHECK-NEXT: tst w8, #0x10000
254- ; CHECK-NEXT: csinv w0, w9 , wzr, eq
250+ ; CHECK-NEXT: and w8, w0 , #0xffff
251+ ; CHECK-NEXT: mvn w9, w1
252+ ; CHECK-NEXT: add w10, w0, w1
253+ ; CHECK-NEXT: cmp w8, w9, uxth
254+ ; CHECK-NEXT: csinv w0, w10 , wzr, ls
255255; CHECK-NEXT: ret
256256 %noty = xor i16 %y , -1
257257 %a = add i16 %x , %y
0 commit comments