Jan Voung | 0ac50dc | 2014-09-30 08:36:06 -0700 | [diff] [blame] | 1 | ; This tries to be a comprehensive test of i8 operations. |
| 2 | |
Jim Stichnoth | 729dbd0 | 2015-02-25 14:48:43 -0800 | [diff] [blame] | 3 | ; RUN: %p2i --filetype=obj --disassemble -i %s --args -O2 | FileCheck %s |
| 4 | ; RUN: %p2i --filetype=obj --disassemble -i %s --args -Om1 | FileCheck %s |
Jan Voung | 0ac50dc | 2014-09-30 08:36:06 -0700 | [diff] [blame] | 5 | |
Jim Stichnoth | a59ae6f | 2015-05-17 10:11:41 -0700 | [diff] [blame] | 6 | declare void @useInt(i32 %x) |
| 7 | |
Jan Voung | 0ac50dc | 2014-09-30 08:36:06 -0700 | [diff] [blame] | 8 | define internal i32 @add8Bit(i32 %a, i32 %b) { |
| 9 | entry: |
| 10 | %a_8 = trunc i32 %a to i8 |
| 11 | %b_8 = trunc i32 %b to i8 |
| 12 | %add = add i8 %b_8, %a_8 |
| 13 | %ret = zext i8 %add to i32 |
| 14 | ret i32 %ret |
| 15 | } |
| 16 | ; CHECK-LABEL: add8Bit |
| 17 | ; CHECK: add {{[abcd]l}} |
| 18 | |
Jan Voung | e4dc61b | 2014-10-06 08:53:52 -0700 | [diff] [blame] | 19 | define internal i32 @add8BitConst(i32 %a) { |
Jan Voung | 0ac50dc | 2014-09-30 08:36:06 -0700 | [diff] [blame] | 20 | entry: |
| 21 | %a_8 = trunc i32 %a to i8 |
| 22 | %add = add i8 %a_8, 123 |
| 23 | %ret = zext i8 %add to i32 |
| 24 | ret i32 %ret |
| 25 | } |
| 26 | ; CHECK-LABEL: add8BitConst |
| 27 | ; CHECK: add {{[abcd]l}} |
| 28 | |
| 29 | define internal i32 @sub8Bit(i32 %a, i32 %b) { |
| 30 | entry: |
| 31 | %a_8 = trunc i32 %a to i8 |
| 32 | %b_8 = trunc i32 %b to i8 |
| 33 | %sub = sub i8 %b_8, %a_8 |
| 34 | %ret = zext i8 %sub to i32 |
| 35 | ret i32 %ret |
| 36 | } |
| 37 | ; CHECK-LABEL: sub8Bit |
Jan Voung | 7b30067 | 2015-02-13 09:47:09 -0800 | [diff] [blame] | 38 | ; CHECK: sub {{[abcd]l}} |
Jan Voung | 0ac50dc | 2014-09-30 08:36:06 -0700 | [diff] [blame] | 39 | |
Jan Voung | e4dc61b | 2014-10-06 08:53:52 -0700 | [diff] [blame] | 40 | define internal i32 @sub8BitConst(i32 %a) { |
Jan Voung | 0ac50dc | 2014-09-30 08:36:06 -0700 | [diff] [blame] | 41 | entry: |
| 42 | %a_8 = trunc i32 %a to i8 |
| 43 | %sub = sub i8 %a_8, 123 |
| 44 | %ret = zext i8 %sub to i32 |
| 45 | ret i32 %ret |
| 46 | } |
| 47 | ; CHECK-LABEL: sub8BitConst |
Jan Voung | 7b30067 | 2015-02-13 09:47:09 -0800 | [diff] [blame] | 48 | ; CHECK: sub {{[abcd]l}} |
Jan Voung | 0ac50dc | 2014-09-30 08:36:06 -0700 | [diff] [blame] | 49 | |
| 50 | define internal i32 @mul8Bit(i32 %a, i32 %b) { |
| 51 | entry: |
| 52 | %a_8 = trunc i32 %a to i8 |
| 53 | %b_8 = trunc i32 %b to i8 |
| 54 | %mul = mul i8 %b_8, %a_8 |
| 55 | %ret = zext i8 %mul to i32 |
| 56 | ret i32 %ret |
| 57 | } |
| 58 | ; CHECK-LABEL: mul8Bit |
Jan Voung | a2703ae | 2015-02-19 11:27:44 -0800 | [diff] [blame] | 59 | ; CHECK: mul {{[abcd]l|BYTE PTR}} |
Jan Voung | 0ac50dc | 2014-09-30 08:36:06 -0700 | [diff] [blame] | 60 | |
Jan Voung | e4dc61b | 2014-10-06 08:53:52 -0700 | [diff] [blame] | 61 | define internal i32 @mul8BitConst(i32 %a) { |
Jan Voung | 0ac50dc | 2014-09-30 08:36:06 -0700 | [diff] [blame] | 62 | entry: |
| 63 | %a_8 = trunc i32 %a to i8 |
| 64 | %mul = mul i8 %a_8, 56 |
| 65 | %ret = zext i8 %mul to i32 |
| 66 | ret i32 %ret |
| 67 | } |
| 68 | ; CHECK-LABEL: mul8BitConst |
| 69 | ; 8-bit imul only accepts r/m, not imm |
Jan Voung | a2703ae | 2015-02-19 11:27:44 -0800 | [diff] [blame] | 70 | ; CHECK: mov {{.*}},0x38 |
| 71 | ; CHECK: mul {{[abcd]l|BYTE PTR}} |
Jan Voung | 0ac50dc | 2014-09-30 08:36:06 -0700 | [diff] [blame] | 72 | |
| 73 | define internal i32 @udiv8Bit(i32 %a, i32 %b) { |
| 74 | entry: |
| 75 | %a_8 = trunc i32 %a to i8 |
| 76 | %b_8 = trunc i32 %b to i8 |
| 77 | %udiv = udiv i8 %b_8, %a_8 |
| 78 | %ret = zext i8 %udiv to i32 |
| 79 | ret i32 %ret |
| 80 | } |
| 81 | ; CHECK-LABEL: udiv8Bit |
Jan Voung | a2703ae | 2015-02-19 11:27:44 -0800 | [diff] [blame] | 82 | ; CHECK: div {{[abcd]l|BYTE PTR}} |
Jan Voung | 0ac50dc | 2014-09-30 08:36:06 -0700 | [diff] [blame] | 83 | |
Jan Voung | e4dc61b | 2014-10-06 08:53:52 -0700 | [diff] [blame] | 84 | define internal i32 @udiv8BitConst(i32 %a) { |
Jan Voung | 0ac50dc | 2014-09-30 08:36:06 -0700 | [diff] [blame] | 85 | entry: |
| 86 | %a_8 = trunc i32 %a to i8 |
| 87 | %udiv = udiv i8 %a_8, 123 |
| 88 | %ret = zext i8 %udiv to i32 |
| 89 | ret i32 %ret |
| 90 | } |
| 91 | ; CHECK-LABEL: udiv8BitConst |
Jan Voung | a2703ae | 2015-02-19 11:27:44 -0800 | [diff] [blame] | 92 | ; CHECK: div {{[abcd]l|BYTE PTR}} |
Jan Voung | 0ac50dc | 2014-09-30 08:36:06 -0700 | [diff] [blame] | 93 | |
| 94 | define internal i32 @urem8Bit(i32 %a, i32 %b) { |
| 95 | entry: |
| 96 | %a_8 = trunc i32 %a to i8 |
| 97 | %b_8 = trunc i32 %b to i8 |
| 98 | %urem = urem i8 %b_8, %a_8 |
| 99 | %ret = zext i8 %urem to i32 |
| 100 | ret i32 %ret |
| 101 | } |
| 102 | ; CHECK-LABEL: urem8Bit |
Jan Voung | a2703ae | 2015-02-19 11:27:44 -0800 | [diff] [blame] | 103 | ; CHECK: div {{[abcd]l|BYTE PTR}} |
Jan Voung | 0ac50dc | 2014-09-30 08:36:06 -0700 | [diff] [blame] | 104 | |
Jan Voung | e4dc61b | 2014-10-06 08:53:52 -0700 | [diff] [blame] | 105 | define internal i32 @urem8BitConst(i32 %a) { |
Jan Voung | 0ac50dc | 2014-09-30 08:36:06 -0700 | [diff] [blame] | 106 | entry: |
| 107 | %a_8 = trunc i32 %a to i8 |
| 108 | %urem = urem i8 %a_8, 123 |
| 109 | %ret = zext i8 %urem to i32 |
| 110 | ret i32 %ret |
| 111 | } |
| 112 | ; CHECK-LABEL: urem8BitConst |
Jan Voung | a2703ae | 2015-02-19 11:27:44 -0800 | [diff] [blame] | 113 | ; CHECK: div {{[abcd]l|BYTE PTR}} |
Jan Voung | 0ac50dc | 2014-09-30 08:36:06 -0700 | [diff] [blame] | 114 | |
| 115 | |
| 116 | define internal i32 @sdiv8Bit(i32 %a, i32 %b) { |
| 117 | entry: |
| 118 | %a_8 = trunc i32 %a to i8 |
| 119 | %b_8 = trunc i32 %b to i8 |
| 120 | %sdiv = sdiv i8 %b_8, %a_8 |
| 121 | %ret = zext i8 %sdiv to i32 |
| 122 | ret i32 %ret |
| 123 | } |
| 124 | ; CHECK-LABEL: sdiv8Bit |
Jan Voung | a2703ae | 2015-02-19 11:27:44 -0800 | [diff] [blame] | 125 | ; CHECK: idiv {{[abcd]l|BYTE PTR}} |
Jan Voung | 0ac50dc | 2014-09-30 08:36:06 -0700 | [diff] [blame] | 126 | |
Jan Voung | e4dc61b | 2014-10-06 08:53:52 -0700 | [diff] [blame] | 127 | define internal i32 @sdiv8BitConst(i32 %a) { |
Jan Voung | 0ac50dc | 2014-09-30 08:36:06 -0700 | [diff] [blame] | 128 | entry: |
| 129 | %a_8 = trunc i32 %a to i8 |
| 130 | %sdiv = sdiv i8 %a_8, 123 |
| 131 | %ret = zext i8 %sdiv to i32 |
| 132 | ret i32 %ret |
| 133 | } |
| 134 | ; CHECK-LABEL: sdiv8BitConst |
Jan Voung | a2703ae | 2015-02-19 11:27:44 -0800 | [diff] [blame] | 135 | ; CHECK: idiv {{[abcd]l|BYTE PTR}} |
Jan Voung | 0ac50dc | 2014-09-30 08:36:06 -0700 | [diff] [blame] | 136 | |
| 137 | define internal i32 @srem8Bit(i32 %a, i32 %b) { |
| 138 | entry: |
| 139 | %a_8 = trunc i32 %a to i8 |
| 140 | %b_8 = trunc i32 %b to i8 |
| 141 | %srem = srem i8 %b_8, %a_8 |
| 142 | %ret = zext i8 %srem to i32 |
| 143 | ret i32 %ret |
| 144 | } |
| 145 | ; CHECK-LABEL: srem8Bit |
Jan Voung | a2703ae | 2015-02-19 11:27:44 -0800 | [diff] [blame] | 146 | ; CHECK: idiv {{[abcd]l|BYTE PTR}} |
Jan Voung | 0ac50dc | 2014-09-30 08:36:06 -0700 | [diff] [blame] | 147 | |
Jan Voung | e4dc61b | 2014-10-06 08:53:52 -0700 | [diff] [blame] | 148 | define internal i32 @srem8BitConst(i32 %a) { |
Jan Voung | 0ac50dc | 2014-09-30 08:36:06 -0700 | [diff] [blame] | 149 | entry: |
| 150 | %a_8 = trunc i32 %a to i8 |
| 151 | %srem = srem i8 %a_8, 123 |
| 152 | %ret = zext i8 %srem to i32 |
| 153 | ret i32 %ret |
| 154 | } |
| 155 | ; CHECK-LABEL: srem8BitConst |
Jan Voung | a2703ae | 2015-02-19 11:27:44 -0800 | [diff] [blame] | 156 | ; CHECK: idiv {{[abcd]l|BYTE PTR}} |
Jan Voung | 0ac50dc | 2014-09-30 08:36:06 -0700 | [diff] [blame] | 157 | |
Jan Voung | 8bcca04 | 2014-10-03 21:58:02 -0700 | [diff] [blame] | 158 | define internal i32 @shl8Bit(i32 %a, i32 %b) { |
| 159 | entry: |
| 160 | %a_8 = trunc i32 %a to i8 |
| 161 | %b_8 = trunc i32 %b to i8 |
| 162 | %shl = shl i8 %b_8, %a_8 |
| 163 | %ret = zext i8 %shl to i32 |
| 164 | ret i32 %ret |
| 165 | } |
| 166 | ; CHECK-LABEL: shl8Bit |
Jan Voung | a2703ae | 2015-02-19 11:27:44 -0800 | [diff] [blame] | 167 | ; CHECK: shl {{[abd]l|BYTE PTR}},cl |
Jan Voung | 8bcca04 | 2014-10-03 21:58:02 -0700 | [diff] [blame] | 168 | |
| 169 | define internal i32 @shl8BitConst(i32 %a, i32 %b) { |
| 170 | entry: |
| 171 | %a_8 = trunc i32 %a to i8 |
| 172 | %shl = shl i8 %a_8, 6 |
| 173 | %ret = zext i8 %shl to i32 |
| 174 | ret i32 %ret |
| 175 | } |
| 176 | ; CHECK-LABEL: shl8BitConst |
Jan Voung | a2703ae | 2015-02-19 11:27:44 -0800 | [diff] [blame] | 177 | ; CHECK: shl {{[abcd]l|BYTE PTR}},0x6 |
Jan Voung | 8bcca04 | 2014-10-03 21:58:02 -0700 | [diff] [blame] | 178 | |
| 179 | define internal i32 @lshr8Bit(i32 %a, i32 %b) { |
| 180 | entry: |
| 181 | %a_8 = trunc i32 %a to i8 |
| 182 | %b_8 = trunc i32 %b to i8 |
| 183 | %lshr = lshr i8 %b_8, %a_8 |
| 184 | %ret = zext i8 %lshr to i32 |
| 185 | ret i32 %ret |
| 186 | } |
| 187 | ; CHECK-LABEL: lshr8Bit |
Jan Voung | a2703ae | 2015-02-19 11:27:44 -0800 | [diff] [blame] | 188 | ; CHECK: shr {{[abd]l|BYTE PTR}},cl |
Jan Voung | 8bcca04 | 2014-10-03 21:58:02 -0700 | [diff] [blame] | 189 | |
| 190 | define internal i32 @lshr8BitConst(i32 %a, i32 %b) { |
| 191 | entry: |
| 192 | %a_8 = trunc i32 %a to i8 |
| 193 | %lshr = lshr i8 %a_8, 6 |
| 194 | %ret = zext i8 %lshr to i32 |
| 195 | ret i32 %ret |
| 196 | } |
| 197 | ; CHECK-LABEL: lshr8BitConst |
Jan Voung | a2703ae | 2015-02-19 11:27:44 -0800 | [diff] [blame] | 198 | ; CHECK: shr {{[abcd]l|BYTE PTR}},0x6 |
Jan Voung | 8bcca04 | 2014-10-03 21:58:02 -0700 | [diff] [blame] | 199 | |
| 200 | define internal i32 @ashr8Bit(i32 %a, i32 %b) { |
| 201 | entry: |
| 202 | %a_8 = trunc i32 %a to i8 |
| 203 | %b_8 = trunc i32 %b to i8 |
| 204 | %ashr = ashr i8 %b_8, %a_8 |
| 205 | %ret = zext i8 %ashr to i32 |
| 206 | ret i32 %ret |
| 207 | } |
| 208 | ; CHECK-LABEL: ashr8Bit |
Jan Voung | a2703ae | 2015-02-19 11:27:44 -0800 | [diff] [blame] | 209 | ; CHECK: sar {{[abd]l|BYTE PTR}},cl |
Jan Voung | 8bcca04 | 2014-10-03 21:58:02 -0700 | [diff] [blame] | 210 | |
| 211 | define internal i32 @ashr8BitConst(i32 %a, i32 %b) { |
| 212 | entry: |
| 213 | %a_8 = trunc i32 %a to i8 |
| 214 | %ashr = ashr i8 %a_8, 6 |
| 215 | %ret = zext i8 %ashr to i32 |
| 216 | ret i32 %ret |
| 217 | } |
| 218 | ; CHECK-LABEL: ashr8BitConst |
Jan Voung | a2703ae | 2015-02-19 11:27:44 -0800 | [diff] [blame] | 219 | ; CHECK: sar {{[abcd]l|BYTE PTR}},0x6 |
Jan Voung | 8bcca04 | 2014-10-03 21:58:02 -0700 | [diff] [blame] | 220 | |
Jan Voung | e4dc61b | 2014-10-06 08:53:52 -0700 | [diff] [blame] | 221 | define internal i32 @icmp8Bit(i32 %a, i32 %b) { |
| 222 | entry: |
| 223 | %a_8 = trunc i32 %a to i8 |
| 224 | %b_8 = trunc i32 %b to i8 |
| 225 | %icmp = icmp ne i8 %b_8, %a_8 |
| 226 | %ret = zext i1 %icmp to i32 |
| 227 | ret i32 %ret |
| 228 | } |
| 229 | ; CHECK-LABEL: icmp8Bit |
Jan Voung | a2703ae | 2015-02-19 11:27:44 -0800 | [diff] [blame] | 230 | ; CHECK: cmp {{[abcd]l|BYTE PTR}} |
Jan Voung | e4dc61b | 2014-10-06 08:53:52 -0700 | [diff] [blame] | 231 | |
| 232 | define internal i32 @icmp8BitConst(i32 %a) { |
| 233 | entry: |
| 234 | %a_8 = trunc i32 %a to i8 |
| 235 | %icmp = icmp ne i8 %a_8, 123 |
| 236 | %ret = zext i1 %icmp to i32 |
| 237 | ret i32 %ret |
| 238 | } |
| 239 | ; CHECK-LABEL: icmp8BitConst |
Jan Voung | a2703ae | 2015-02-19 11:27:44 -0800 | [diff] [blame] | 240 | ; CHECK: cmp {{[abcd]l|BYTE PTR}} |
Jan Voung | e4dc61b | 2014-10-06 08:53:52 -0700 | [diff] [blame] | 241 | |
| 242 | define internal i32 @icmp8BitConstSwapped(i32 %a) { |
| 243 | entry: |
| 244 | %a_8 = trunc i32 %a to i8 |
| 245 | %icmp = icmp ne i8 123, %a_8 |
| 246 | %ret = zext i1 %icmp to i32 |
| 247 | ret i32 %ret |
| 248 | } |
| 249 | ; CHECK-LABEL: icmp8BitConstSwapped |
Jan Voung | a2703ae | 2015-02-19 11:27:44 -0800 | [diff] [blame] | 250 | ; CHECK: cmp {{[abcd]l|BYTE PTR}} |
Jan Voung | e4dc61b | 2014-10-06 08:53:52 -0700 | [diff] [blame] | 251 | |
| 252 | define internal i32 @icmp8BitMem(i32 %a, i32 %b_iptr) { |
| 253 | entry: |
| 254 | %a_8 = trunc i32 %a to i8 |
| 255 | %bptr = inttoptr i32 %b_iptr to i8* |
Jim Stichnoth | e5b58fb | 2015-06-01 15:17:20 -0700 | [diff] [blame] | 256 | %b_8 = load i8, i8* %bptr, align 1 |
Jan Voung | e4dc61b | 2014-10-06 08:53:52 -0700 | [diff] [blame] | 257 | %icmp = icmp ne i8 %b_8, %a_8 |
| 258 | %ret = zext i1 %icmp to i32 |
| 259 | ret i32 %ret |
| 260 | } |
| 261 | ; CHECK-LABEL: icmp8BitMem |
Jan Voung | a2703ae | 2015-02-19 11:27:44 -0800 | [diff] [blame] | 262 | ; CHECK: cmp {{[abcd]l|BYTE PTR}} |
Jan Voung | e4dc61b | 2014-10-06 08:53:52 -0700 | [diff] [blame] | 263 | |
| 264 | define internal i32 @icmp8BitMemSwapped(i32 %a, i32 %b_iptr) { |
| 265 | entry: |
| 266 | %a_8 = trunc i32 %a to i8 |
| 267 | %bptr = inttoptr i32 %b_iptr to i8* |
Jim Stichnoth | e5b58fb | 2015-06-01 15:17:20 -0700 | [diff] [blame] | 268 | %b_8 = load i8, i8* %bptr, align 1 |
Jan Voung | e4dc61b | 2014-10-06 08:53:52 -0700 | [diff] [blame] | 269 | %icmp = icmp ne i8 %a_8, %b_8 |
| 270 | %ret = zext i1 %icmp to i32 |
| 271 | ret i32 %ret |
| 272 | } |
| 273 | ; CHECK-LABEL: icmp8BitMemSwapped |
Jan Voung | a2703ae | 2015-02-19 11:27:44 -0800 | [diff] [blame] | 274 | ; CHECK: cmp {{[abcd]l|BYTE PTR}} |
Jan Voung | 0ac50dc | 2014-09-30 08:36:06 -0700 | [diff] [blame] | 275 | |
Jan Voung | 198b294 | 2014-10-16 09:40:02 -0700 | [diff] [blame] | 276 | define internal i32 @selectI8Var(i32 %a, i32 %b) { |
| 277 | entry: |
| 278 | %a_8 = trunc i32 %a to i8 |
| 279 | %b_8 = trunc i32 %b to i8 |
| 280 | %cmp = icmp slt i8 %a_8, %b_8 |
| 281 | %ret = select i1 %cmp, i8 %a_8, i8 %b_8 |
| 282 | %ret_ext = zext i8 %ret to i32 |
Jim Stichnoth | a59ae6f | 2015-05-17 10:11:41 -0700 | [diff] [blame] | 283 | ; Create a "fake" use of %cmp to prevent O2 bool folding. |
| 284 | %d1 = zext i1 %cmp to i32 |
| 285 | call void @useInt(i32 %d1) |
Jan Voung | 198b294 | 2014-10-16 09:40:02 -0700 | [diff] [blame] | 286 | ret i32 %ret_ext |
| 287 | } |
| 288 | ; CHECK-LABEL: selectI8Var |
| 289 | ; CHECK: cmp |
Jim Stichnoth | f48b320 | 2015-05-04 10:22:17 -0700 | [diff] [blame] | 290 | ; CHECK: setl |
Jan Voung | 198b294 | 2014-10-16 09:40:02 -0700 | [diff] [blame] | 291 | ; CHECK: mov {{[a-d]l}} |
| 292 | |
Jan Voung | fe14fb8 | 2014-10-13 15:56:32 -0700 | [diff] [blame] | 293 | define internal i32 @testPhi8(i32 %arg, i32 %arg2, i32 %arg3, i32 %arg4, i32 %arg5, i32 %arg6, i32 %arg7, i32 %arg8, i32 %arg9, i32 %arg10) { |
| 294 | entry: |
| 295 | %trunc = trunc i32 %arg to i8 |
| 296 | %trunc2 = trunc i32 %arg2 to i8 |
| 297 | %trunc3 = trunc i32 %arg3 to i8 |
| 298 | %trunc4 = trunc i32 %arg4 to i8 |
| 299 | %trunc5 = trunc i32 %arg5 to i8 |
| 300 | %cmp1 = icmp sgt i32 %arg, 0 |
| 301 | br i1 %cmp1, label %next, label %target |
| 302 | next: |
| 303 | %trunc6_16 = trunc i32 %arg6 to i16 |
| 304 | %trunc7_16 = trunc i32 %arg7 to i16 |
| 305 | %trunc8_16 = trunc i32 %arg8 to i16 |
| 306 | %trunc9 = trunc i32 %arg9 to i8 |
| 307 | %trunc10 = trunc i32 %arg10 to i8 |
| 308 | %trunc7_8 = trunc i16 %trunc7_16 to i8 |
| 309 | %trunc6_8 = trunc i16 %trunc6_16 to i8 |
| 310 | %trunc8_8 = trunc i16 %trunc8_16 to i8 |
| 311 | br label %target |
| 312 | target: |
| 313 | %merge1 = phi i1 [ %cmp1, %entry ], [ false, %next ] |
| 314 | %merge2 = phi i8 [ %trunc, %entry ], [ %trunc6_8, %next ] |
| 315 | %merge3 = phi i8 [ %trunc2, %entry ], [ %trunc7_8, %next ] |
| 316 | %merge5 = phi i8 [ %trunc4, %entry ], [ %trunc9, %next ] |
| 317 | %merge6 = phi i8 [ %trunc5, %entry ], [ %trunc10, %next ] |
| 318 | %merge4 = phi i8 [ %trunc3, %entry ], [ %trunc8_8, %next ] |
| 319 | %res1 = select i1 %merge1, i8 %merge2, i8 %merge3 |
| 320 | %res2 = select i1 %merge1, i8 %merge4, i8 %merge5 |
| 321 | %res1_2 = select i1 %merge1, i8 %res1, i8 %res2 |
| 322 | %res123 = select i1 %merge1, i8 %merge6, i8 %res1_2 |
| 323 | %result = zext i8 %res123 to i32 |
| 324 | ret i32 %result |
| 325 | } |
| 326 | ; CHECK-LABEL: testPhi8 |
| 327 | ; This assumes there will be some copy from an 8-bit register / stack slot. |
Jan Voung | a2703ae | 2015-02-19 11:27:44 -0800 | [diff] [blame] | 328 | ; CHECK-DAG: mov {{.*}},{{[a-d]}}l |
| 329 | ; CHECK-DAG: mov {{.*}},BYTE PTR |
| 330 | ; CHECK-DAG: mov BYTE PTR {{.*}} |
Jan Voung | fe14fb8 | 2014-10-13 15:56:32 -0700 | [diff] [blame] | 331 | |
Jan Voung | 198b294 | 2014-10-16 09:40:02 -0700 | [diff] [blame] | 332 | @global8 = internal global [1 x i8] c"\01", align 4 |
| 333 | |
| 334 | define i32 @load_i8(i32 %addr_arg) { |
| 335 | entry: |
| 336 | %addr = inttoptr i32 %addr_arg to i8* |
Jim Stichnoth | e5b58fb | 2015-06-01 15:17:20 -0700 | [diff] [blame] | 337 | %ret = load i8, i8* %addr, align 1 |
Jim Stichnoth | c77f817 | 2015-05-31 23:34:44 -0700 | [diff] [blame] | 338 | %ret2 = sub i8 %ret, 0 |
| 339 | %ret_ext = zext i8 %ret2 to i32 |
Jan Voung | 198b294 | 2014-10-16 09:40:02 -0700 | [diff] [blame] | 340 | ret i32 %ret_ext |
| 341 | } |
| 342 | ; CHECK-LABEL: load_i8 |
Jan Voung | a2703ae | 2015-02-19 11:27:44 -0800 | [diff] [blame] | 343 | ; CHECK: mov {{[a-d]l}},BYTE PTR |
Jan Voung | 198b294 | 2014-10-16 09:40:02 -0700 | [diff] [blame] | 344 | |
| 345 | define i32 @load_i8_global(i32 %addr_arg) { |
| 346 | entry: |
| 347 | %addr = bitcast [1 x i8]* @global8 to i8* |
Jim Stichnoth | e5b58fb | 2015-06-01 15:17:20 -0700 | [diff] [blame] | 348 | %ret = load i8, i8* %addr, align 1 |
Jim Stichnoth | c77f817 | 2015-05-31 23:34:44 -0700 | [diff] [blame] | 349 | %ret2 = sub i8 %ret, 0 |
| 350 | %ret_ext = zext i8 %ret2 to i32 |
Jan Voung | 198b294 | 2014-10-16 09:40:02 -0700 | [diff] [blame] | 351 | ret i32 %ret_ext |
| 352 | } |
| 353 | ; CHECK-LABEL: load_i8_global |
Jan Voung | a2703ae | 2015-02-19 11:27:44 -0800 | [diff] [blame] | 354 | ; CHECK: mov {{[a-d]l}},BYTE PTR |
Jan Voung | 198b294 | 2014-10-16 09:40:02 -0700 | [diff] [blame] | 355 | |
| 356 | define void @store_i8(i32 %addr_arg, i32 %val) { |
| 357 | entry: |
| 358 | %val_trunc = trunc i32 %val to i8 |
| 359 | %addr = inttoptr i32 %addr_arg to i8* |
| 360 | store i8 %val_trunc, i8* %addr, align 1 |
| 361 | ret void |
| 362 | } |
| 363 | ; CHECK-LABEL: store_i8 |
Jan Voung | a2703ae | 2015-02-19 11:27:44 -0800 | [diff] [blame] | 364 | ; CHECK: mov BYTE PTR {{.*}},{{[a-d]l}} |
Jan Voung | 198b294 | 2014-10-16 09:40:02 -0700 | [diff] [blame] | 365 | |
| 366 | define void @store_i8_const(i32 %addr_arg) { |
| 367 | entry: |
| 368 | %addr = inttoptr i32 %addr_arg to i8* |
| 369 | store i8 123, i8* %addr, align 1 |
| 370 | ret void |
| 371 | } |
| 372 | ; CHECK-LABEL: store_i8_const |
Jan Voung | a2703ae | 2015-02-19 11:27:44 -0800 | [diff] [blame] | 373 | ; CHECK: mov BYTE PTR {{.*}},0x7b |