1 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-unknown \
2 ; RUN: -ppc-asm-full-reg-names -mcpu=pwr9 < %s | FileCheck %s
3 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-unknown \
4 ; RUN: -ppc-asm-full-reg-names -mcpu=pwr9 < %s | FileCheck %s
6 define i64 @addze1(i64 %X, i64 %Z) {
9 ; CHECK-NEXT: addic [[REG1:r[0-9]+]], [[REG1]], -1
10 ; CHECK-NEXT: addze [[REG2:r[0-9]+]], [[REG2]]
12 %cmp = icmp ne i64 %Z, 0
13 %conv1 = zext i1 %cmp to i64
14 %add = add nsw i64 %conv1, %X
18 define i64 @addze2(i64 %X, i64 %Z) {
19 ; CHECK-LABEL: addze2:
21 ; CHECK-NEXT: subfic [[REG1:r[0-9]+]], [[REG1]], 0
22 ; CHECK-NEXT: addze [[REG2:r[0-9]+]], [[REG2]]
24 %cmp = icmp eq i64 %Z, 0
25 %conv1 = zext i1 %cmp to i64
26 %add = add nsw i64 %conv1, %X
30 define i64 @addze3(i64 %X, i64 %Z) {
31 ; CHECK-LABEL: addze3:
33 ; CHECK-NEXT: addi [[REG1:r[0-9]+]], [[REG1]], -32768
34 ; CHECK-NEXT: addic [[REG1]], [[REG1]], -1
35 ; CHECK-NEXT: addze [[REG2:r[0-9]+]], [[REG2]]
37 %cmp = icmp ne i64 %Z, 32768
38 %conv1 = zext i1 %cmp to i64
39 %add = add nsw i64 %conv1, %X
43 define i64 @addze4(i64 %X, i64 %Z) {
44 ; CHECK-LABEL: addze4:
46 ; CHECK-NEXT: addi [[REG1:r[0-9]+]], [[REG1]], -32768
47 ; CHECK-NEXT: subfic [[REG1]], [[REG1]], 0
48 ; CHECK-NEXT: addze [[REG2:r[0-9]+]], [[REG2]]
50 %cmp = icmp eq i64 %Z, 32768
51 %conv1 = zext i1 %cmp to i64
52 %add = add nsw i64 %conv1, %X
56 define i64 @addze5(i64 %X, i64 %Z) {
57 ; CHECK-LABEL: addze5:
59 ; CHECK-NEXT: addi [[REG1:r[0-9]+]], [[REG1]], 32767
60 ; CHECK-NEXT: addic [[REG1]], [[REG1]], -1
61 ; CHECK-NEXT: addze [[REG2:r[0-9]+]], [[REG2]]
63 %cmp = icmp ne i64 %Z, -32767
64 %conv1 = zext i1 %cmp to i64
65 %add = add nsw i64 %conv1, %X
69 define i64 @addze6(i64 %X, i64 %Z) {
70 ; CHECK-LABEL: addze6:
72 ; CHECK-NEXT: addi [[REG1:r[0-9]+]], [[REG1]], 32767
73 ; CHECK-NEXT: subfic [[REG1]], [[REG1]], 0
74 ; CHECK-NEXT: addze [[REG2:r[0-9]+]], [[REG2]]
76 %cmp = icmp eq i64 %Z, -32767
77 %conv1 = zext i1 %cmp to i64
78 %add = add nsw i64 %conv1, %X
82 ; element is out of range
83 define i64 @test1(i64 %X, i64 %Z) {
86 ; CHECK-NEXT: li [[REG1:r[0-9]+]], -32768
87 ; CHECK-NEXT: xor [[REG2:r[0-9]+]], [[REG2]], [[REG1]]
88 ; CHECK-NEXT: addic [[REG1]], [[REG2]], -1
89 ; CHECK-NEXT: subfe [[REG2]], [[REG1]], [[REG2]]
90 ; CHECK-NEXT: add [[REG3:r[0-9]+]], [[REG2]], [[REG3]]
92 %cmp = icmp ne i64 %Z, -32768
93 %conv1 = zext i1 %cmp to i64
94 %add = add nsw i64 %conv1, %X
98 define i64 @test2(i64 %X, i64 %Z) {
101 ; CHECK-NEXT: li [[REG1:r[0-9]+]], -32768
102 ; CHECK-NEXT: xor [[REG2:r[0-9]+]], [[REG2]], [[REG1]]
103 ; CHECK-NEXT: cntlzd [[REG2]], [[REG2]]
104 ; CHECK-NEXT: rldicl [[REG2]], [[REG2]], 58, 63
105 ; CHECK-NEXT: add [[REG3:r[0-9]+]], [[REG2]], [[REG3]]
107 %cmp = icmp eq i64 %Z, -32768
108 %conv1 = zext i1 %cmp to i64
109 %add = add nsw i64 %conv1, %X
113 define i64 @test3(i64 %X, i64 %Z) {
114 ; CHECK-LABEL: test3:
116 ; CHECK-NEXT: li [[REG1:r[0-9]+]], 0
117 ; CHECK-NEXT: ori [[REG1]], [[REG1]], 32769
118 ; CHECK-NEXT: xor [[REG2:r[0-9]+]], [[REG2]], [[REG1]]
119 ; CHECK-NEXT: addic [[REG1]], [[REG2]], -1
120 ; CHECK-NEXT: subfe [[REG2]], [[REG1]], [[REG2]]
121 ; CHECK-NEXT: add [[REG3:r[0-9]+]], [[REG2]], [[REG3]]
123 %cmp = icmp ne i64 %Z, 32769
124 %conv1 = zext i1 %cmp to i64
125 %add = add nsw i64 %conv1, %X
129 define i64 @test4(i64 %X, i64 %Z) {
130 ; CHECK-LABEL: test4:
132 ; CHECK-NEXT: li [[REG1:r[0-9]+]], 0
133 ; CHECK-NEXT: ori [[REG1]], [[REG1]], 32769
134 ; CHECK-NEXT: xor [[REG2:r[0-9]+]], [[REG2]], [[REG1]]
135 ; CHECK-NEXT: cntlzd [[REG2]], [[REG2]]
136 ; CHECK-NEXT: rldicl [[REG2]], [[REG2]], 58, 63
137 ; CHECK-NEXT: add [[REG3:r[0-9]+]], [[REG2]], [[REG3]]
139 %cmp = icmp eq i64 %Z, 32769
140 %conv1 = zext i1 %cmp to i64
141 %add = add nsw i64 %conv1, %X
145 ; comparison of two registers
146 define i64 @test5(i64 %X, i64 %Y, i64 %Z) {
147 ; CHECK-LABEL: test5:
149 ; CHECK-NEXT: xor [[REG2:r[0-9]+]], [[REG2]], [[REG1:r[0-9]+]]
150 ; CHECK-NEXT: addic [[REG1]], [[REG2]], -1
151 ; CHECK-NEXT: subfe [[REG2]], [[REG1]], [[REG2]]
152 ; CHECK-NEXT: add [[REG3:r[0-9]+]], [[REG2]], [[REG3]]
154 %cmp = icmp ne i64 %Y, %Z
155 %conv1 = zext i1 %cmp to i64
156 %add = add nsw i64 %conv1, %X
160 define i64 @test6(i64 %X, i64 %Y, i64 %Z) {
161 ; CHECK-LABEL: test6:
163 ; CHECK-NEXT: xor [[REG2:r[0-9]+]], [[REG2]], [[REG1:r[0-9]+]]
164 ; CHECK-NEXT: cntlzd [[REG2]], [[REG2]]
165 ; CHECK-NEXT: rldicl [[REG2]], [[REG2]], 58, 63
166 ; CHECK-NEXT: add [[REG3:r[0-9]+]], [[REG2]], [[REG3]]
168 %cmp = icmp eq i64 %Y, %Z
169 %conv1 = zext i1 %cmp to i64
170 %add = add nsw i64 %conv1, %X