1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -verify-machineinstrs < %s -mtriple=powerpc64le-unknown-linux-gnu | FileCheck %s
4 declare { i8, i1 } @llvm.sadd.with.overflow.i8(i8, i8) nounwind readnone
5 declare { i16, i1 } @llvm.sadd.with.overflow.i16(i16, i16) nounwind readnone
6 declare { i32, i1 } @llvm.sadd.with.overflow.i32(i32, i32) nounwind readnone
7 declare { i64, i1 } @llvm.sadd.with.overflow.i64(i64, i64) nounwind readnone
8 declare { <4 x i32>, <4 x i1> } @llvm.sadd.with.overflow.v4i32(<4 x i32>, <4 x i32>) nounwind readnone
9 declare { i8, i1 } @llvm.ssub.with.overflow.i8(i8, i8) nounwind readnone
10 declare { i16, i1 } @llvm.ssub.with.overflow.i16(i16, i16) nounwind readnone
11 declare { i32, i1 } @llvm.ssub.with.overflow.i32(i32, i32) nounwind readnone
12 declare { i64, i1 } @llvm.ssub.with.overflow.i64(i64, i64) nounwind readnone
13 declare { <4 x i32>, <4 x i1> } @llvm.ssub.with.overflow.v4i32(<4 x i32>, <4 x i32>) nounwind readnone
15 define i1 @test_saddo_i8(i8 %a, i8 %b) nounwind {
16 ; CHECK-LABEL: test_saddo_i8:
17 ; CHECK: # %bb.0: # %entry
18 ; CHECK-NEXT: extsb 4, 4
19 ; CHECK-NEXT: extsb 3, 3
20 ; CHECK-NEXT: add 3, 3, 4
21 ; CHECK-NEXT: extsb 4, 3
22 ; CHECK-NEXT: cmpw 4, 3
24 ; CHECK-NEXT: iseleq 3, 0, 3
27 %res = call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 %a, i8 %b) nounwind
28 %overflow = extractvalue { i8, i1 } %res, 1
32 define i1 @test_saddo_i16(i16 %a, i16 %b) nounwind {
33 ; CHECK-LABEL: test_saddo_i16:
34 ; CHECK: # %bb.0: # %entry
35 ; CHECK-NEXT: extsh 4, 4
36 ; CHECK-NEXT: extsh 3, 3
37 ; CHECK-NEXT: add 3, 3, 4
38 ; CHECK-NEXT: extsh 4, 3
39 ; CHECK-NEXT: cmpw 4, 3
41 ; CHECK-NEXT: iseleq 3, 0, 3
44 %res = call { i16, i1 } @llvm.sadd.with.overflow.i16(i16 %a, i16 %b) nounwind
45 %overflow = extractvalue { i16, i1 } %res, 1
49 define i1 @test_saddo_i32(i32 %a, i32 %b) nounwind {
50 ; CHECK-LABEL: test_saddo_i32:
51 ; CHECK: # %bb.0: # %entry
52 ; CHECK-NEXT: add 5, 3, 4
53 ; CHECK-NEXT: cmpwi 1, 4, 0
54 ; CHECK-NEXT: cmpw 5, 3
56 ; CHECK-NEXT: creqv 20, 4, 0
57 ; CHECK-NEXT: isel 3, 0, 3, 20
60 %res = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 %a, i32 %b) nounwind
61 %overflow = extractvalue { i32, i1 } %res, 1
65 define i1 @test_saddo_i64(i64 %a, i64 %b) nounwind {
66 ; CHECK-LABEL: test_saddo_i64:
67 ; CHECK: # %bb.0: # %entry
68 ; CHECK-NEXT: add 5, 3, 4
69 ; CHECK-NEXT: cmpdi 1, 4, 0
70 ; CHECK-NEXT: cmpd 5, 3
72 ; CHECK-NEXT: creqv 20, 4, 0
73 ; CHECK-NEXT: isel 3, 0, 3, 20
76 %res = call { i64, i1 } @llvm.sadd.with.overflow.i64(i64 %a, i64 %b) nounwind
77 %overflow = extractvalue { i64, i1 } %res, 1
81 define <4 x i1> @test_saddo_v4i32(<4 x i32> %a, <4 x i32> %b) nounwind {
82 ; CHECK-LABEL: test_saddo_v4i32:
83 ; CHECK: # %bb.0: # %entry
84 ; CHECK-NEXT: vaddsws 4, 2, 3
85 ; CHECK-NEXT: vadduwm 2, 2, 3
86 ; CHECK-NEXT: vcmpequw 2, 2, 4
87 ; CHECK-NEXT: xxlnor 34, 34, 34
90 %res = call { <4 x i32>, <4 x i1> } @llvm.sadd.with.overflow.v4i32(<4 x i32> %a, <4 x i32> %b) nounwind
91 %overflow = extractvalue { <4 x i32>, <4 x i1> } %res, 1
92 ret <4 x i1> %overflow
95 define i1 @test_ssubo_i8(i8 %a, i8 %b) nounwind {
96 ; CHECK-LABEL: test_ssubo_i8:
97 ; CHECK: # %bb.0: # %entry
98 ; CHECK-NEXT: extsb 3, 3
99 ; CHECK-NEXT: extsb 4, 4
100 ; CHECK-NEXT: sub 3, 3, 4
101 ; CHECK-NEXT: extsb 4, 3
102 ; CHECK-NEXT: cmpw 4, 3
103 ; CHECK-NEXT: li 3, 1
104 ; CHECK-NEXT: iseleq 3, 0, 3
107 %res = call { i8, i1 } @llvm.ssub.with.overflow.i8(i8 %a, i8 %b) nounwind
108 %overflow = extractvalue { i8, i1 } %res, 1
112 define i1 @test_ssubo_i16(i16 %a, i16 %b) nounwind {
113 ; CHECK-LABEL: test_ssubo_i16:
114 ; CHECK: # %bb.0: # %entry
115 ; CHECK-NEXT: extsh 3, 3
116 ; CHECK-NEXT: extsh 4, 4
117 ; CHECK-NEXT: sub 3, 3, 4
118 ; CHECK-NEXT: extsh 4, 3
119 ; CHECK-NEXT: cmpw 4, 3
120 ; CHECK-NEXT: li 3, 1
121 ; CHECK-NEXT: iseleq 3, 0, 3
124 %res = call { i16, i1 } @llvm.ssub.with.overflow.i16(i16 %a, i16 %b) nounwind
125 %overflow = extractvalue { i16, i1 } %res, 1
129 define i1 @test_ssubo_i32(i32 %a, i32 %b) nounwind {
130 ; CHECK-LABEL: test_ssubo_i32:
131 ; CHECK: # %bb.0: # %entry
132 ; CHECK-NEXT: xor 5, 4, 3
133 ; CHECK-NEXT: sub 4, 3, 4
134 ; CHECK-NEXT: xor 3, 4, 3
135 ; CHECK-NEXT: and 3, 5, 3
136 ; CHECK-NEXT: srwi 3, 3, 31
139 %res = call { i32, i1 } @llvm.ssub.with.overflow.i32(i32 %a, i32 %b) nounwind
140 %overflow = extractvalue { i32, i1 } %res, 1
144 define i1 @test_ssubo_i64(i64 %a, i64 %b) nounwind {
145 ; CHECK-LABEL: test_ssubo_i64:
146 ; CHECK: # %bb.0: # %entry
147 ; CHECK-NEXT: xor 5, 4, 3
148 ; CHECK-NEXT: sub 4, 3, 4
149 ; CHECK-NEXT: xor 3, 4, 3
150 ; CHECK-NEXT: and 3, 5, 3
151 ; CHECK-NEXT: rldicl 3, 3, 1, 63
154 %res = call { i64, i1 } @llvm.ssub.with.overflow.i64(i64 %a, i64 %b) nounwind
155 %overflow = extractvalue { i64, i1 } %res, 1
159 define <4 x i1> @test_ssubo_v4i32(<4 x i32> %a, <4 x i32> %b) nounwind {
160 ; CHECK-LABEL: test_ssubo_v4i32:
161 ; CHECK: # %bb.0: # %entry
162 ; CHECK-NEXT: vsubsws 4, 2, 3
163 ; CHECK-NEXT: vsubuwm 2, 2, 3
164 ; CHECK-NEXT: vcmpequw 2, 2, 4
165 ; CHECK-NEXT: xxlnor 34, 34, 34
168 %res = call { <4 x i32>, <4 x i1> } @llvm.ssub.with.overflow.v4i32(<4 x i32> %a, <4 x i32> %b) nounwind
169 %overflow = extractvalue { <4 x i32>, <4 x i1> } %res, 1
170 ret <4 x i1> %overflow