OLD | NEW |
1 ; Tests various aspects of x86 immediate encoding. Some encodings are shorter. | 1 ; Tests various aspects of x86 immediate encoding. Some encodings are shorter. |
2 ; For example, the encoding is shorter for 8-bit immediates or when using EAX. | 2 ; For example, the encoding is shorter for 8-bit immediates or when using EAX. |
3 ; This assumes that EAX is chosen as the first free register in O2 mode. | 3 ; This assumes that EAX is chosen as the first free register in O2 mode. |
4 | 4 |
5 ; RUN: %p2i -i %s --args -O2 --verbose none \ | 5 ; RUN: %p2i -i %s --args -O2 --verbose none \ |
6 ; RUN: | llvm-mc -triple=i686-none-nacl -x86-asm-syntax=intel -filetype=obj \ | 6 ; RUN: | llvm-mc -triple=i686-none-nacl -x86-asm-syntax=intel -filetype=obj \ |
7 ; RUN: | llvm-objdump -d --symbolize -x86-asm-syntax=intel - | FileCheck %s | 7 ; RUN: | llvm-objdump -d --symbolize -x86-asm-syntax=intel - | FileCheck %s |
8 ; RUN: %p2i -i %s --args --verbose none | FileCheck --check-prefix=ERRORS %s | 8 ; RUN: %p2i -i %s --args --verbose none | FileCheck --check-prefix=ERRORS %s |
9 ; RUN: %p2i -i %s --insts | %szdiff %s | FileCheck --check-prefix=DUMP %s | 9 ; RUN: %p2i -i %s --insts | %szdiff %s | FileCheck --check-prefix=DUMP %s |
10 | 10 |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 define internal i32 @testSub8Imm8(i32 %arg) { | 164 define internal i32 @testSub8Imm8(i32 %arg) { |
165 entry: | 165 entry: |
166 %arg_i8 = trunc i32 %arg to i8 | 166 %arg_i8 = trunc i32 %arg to i8 |
167 %result_i8 = sub i8 %arg_i8, 125 | 167 %result_i8 = sub i8 %arg_i8, 125 |
168 %result = zext i8 %result_i8 to i32 | 168 %result = zext i8 %result_i8 to i32 |
169 ret i32 %result | 169 ret i32 %result |
170 } | 170 } |
171 ; CHECK-LABEL: testSub8Imm8 | 171 ; CHECK-LABEL: testSub8Imm8 |
172 ; CHECK: 2c 7d sub al, 125 | 172 ; CHECK: 2c 7d sub al, 125 |
173 | 173 |
| 174 ; imul has some shorter 8-bit immediate encodings. |
| 175 ; It also has a shorter encoding for eax, but we don't do that yet. |
| 176 |
| 177 define internal i32 @testMul16Imm8(i32 %arg) { |
| 178 entry: |
| 179 %arg_i16 = trunc i32 %arg to i16 |
| 180 %tmp = mul i16 %arg_i16, 99 |
| 181 %result_i16 = add i16 %tmp, 1 |
| 182 %result = zext i16 %result_i16 to i32 |
| 183 ret i32 %result |
| 184 } |
| 185 ; CHECK-LABEL: testMul16Imm8 |
| 186 ; CHECK: 66 6b c0 63 imul ax, ax, 99 |
| 187 ; CHECK-NEXT: add ax, 1 |
| 188 |
| 189 define internal i32 @testMul16Imm8Neg(i32 %arg) { |
| 190 entry: |
| 191 %arg_i16 = trunc i32 %arg to i16 |
| 192 %tmp = mul i16 %arg_i16, -111 |
| 193 %result_i16 = add i16 %tmp, 1 |
| 194 %result = zext i16 %result_i16 to i32 |
| 195 ret i32 %result |
| 196 } |
| 197 ; CHECK-LABEL: testMul16Imm8Neg |
| 198 ; CHECK: 66 6b c0 91 imul ax, ax, 145 |
| 199 ; CHECK-NEXT: add ax, 1 |
| 200 |
| 201 define internal i32 @testMul16Imm16(i32 %arg) { |
| 202 entry: |
| 203 %arg_i16 = trunc i32 %arg to i16 |
| 204 %tmp = mul i16 %arg_i16, 1024 |
| 205 %result_i16 = add i16 %tmp, 1 |
| 206 %result = zext i16 %result_i16 to i32 |
| 207 ret i32 %result |
| 208 } |
| 209 ; CHECK-LABEL: testMul16Imm16 |
| 210 ; CHECK: 66 69 c0 00 04 imul ax, ax, 1024 |
| 211 ; CHECK-NEXT: add ax, 1 |
| 212 |
| 213 define internal i32 @testMul16Imm16Neg(i32 %arg) { |
| 214 entry: |
| 215 %arg_i16 = trunc i32 %arg to i16 |
| 216 %tmp = mul i16 %arg_i16, -256 |
| 217 %result_i16 = add i16 %tmp, 1 |
| 218 %result = zext i16 %result_i16 to i32 |
| 219 ret i32 %result |
| 220 } |
| 221 ; CHECK-LABEL: testMul16Imm16Neg |
| 222 ; CHECK: 66 69 c0 00 ff imul ax, ax, 65280 |
| 223 ; CHECK-NEXT: add ax, 1 |
| 224 |
| 225 define internal i32 @testMul32Imm8(i32 %arg) { |
| 226 entry: |
| 227 %result = mul i32 %arg, 99 |
| 228 ret i32 %result |
| 229 } |
| 230 ; CHECK-LABEL: testMul32Imm8 |
| 231 ; CHECK: 6b c0 63 imul eax, eax, 99 |
| 232 |
| 233 define internal i32 @testMul32Imm8Neg(i32 %arg) { |
| 234 entry: |
| 235 %result = mul i32 %arg, -111 |
| 236 ret i32 %result |
| 237 } |
| 238 ; CHECK-LABEL: testMul32Imm8Neg |
| 239 ; CHECK: 6b c0 91 imul eax, eax, -111 |
| 240 |
| 241 define internal i32 @testMul32Imm16(i32 %arg) { |
| 242 entry: |
| 243 %result = mul i32 %arg, 1024 |
| 244 ret i32 %result |
| 245 } |
| 246 ; CHECK-LABEL: testMul32Imm16 |
| 247 ; CHECK: 69 c0 00 04 00 00 imul eax, eax, 1024 |
| 248 |
| 249 define internal i32 @testMul32Imm16Neg(i32 %arg) { |
| 250 entry: |
| 251 %result = mul i32 %arg, -256 |
| 252 ret i32 %result |
| 253 } |
| 254 ; CHECK-LABEL: testMul32Imm16Neg |
| 255 ; CHECK: 69 c0 00 ff ff ff imul eax, eax, 4294967040 |
| 256 |
174 ; ERRORS-NOT: ICE translation error | 257 ; ERRORS-NOT: ICE translation error |
175 ; DUMP-NOT: SZ | 258 ; DUMP-NOT: SZ |
OLD | NEW |