File tree Expand file tree Collapse file tree 7 files changed +156
-7
lines changed
filetests/filetests/isa/x64 Expand file tree Collapse file tree 7 files changed +156
-7
lines changed Original file line number Diff line number Diff line change 2884
2884
(rule 2 (x64_imul_imm $I16 src1 (i8_try_from_i32 src2)) (x64_imulw_rmi_sxb src1 src2))
2885
2885
(rule 2 (x64_imul_imm $I32 src1 (i8_try_from_i32 src2)) (x64_imull_rmi_sxb src1 src2))
2886
2886
(rule 2 (x64_imul_imm $I64 src1 (i8_try_from_i32 src2)) (x64_imulq_rmi_sxb src1 src2))
2887
- (rule 1 (x64_imul_imm $I16 src1 (u16_try_from_i32 src2)) (x64_imulw_rmi src1 src2))
2888
- (rule 1 (x64_imul_imm $I32 src1 (i32_as_u32 src2)) (x64_imull_rmi src1 src2))
2889
- (rule 1 (x64_imul_imm $I64 src1 src2) (x64_imulq_rmi_sxl src1 src2))
2887
+ (rule 1 (x64_imul_imm $I16 src1 (i16_try_from_i32 src2)) (x64_imulw_rmi src1 (i16_as_u16 src2) ))
2888
+ (rule 1 (x64_imul_imm $I32 src1 src2) (x64_imull_rmi src1 (i32_as_u32 src2) ))
2889
+ (rule 1 (x64_imul_imm $I64 src1 src2) (x64_imulq_rmi_sxl src1 src2))
2890
2890
2891
2891
;; Helper for creating `mul` instructions or `imul` instructions (depending
2892
2892
;; on `signed`) for 8-bit operands.
Original file line number Diff line number Diff line change @@ -59,8 +59,8 @@ macro_rules! isle_common_prelude_methods {
59
59
}
60
60
61
61
#[ inline]
62
- fn i32_as_u32( & mut self , x: i32 ) -> Option < u32 > {
63
- Some ( x as u32 )
62
+ fn i32_as_u32( & mut self , x: i32 ) -> u32 {
63
+ x as u32
64
64
}
65
65
66
66
#[ inline]
@@ -958,6 +958,14 @@ macro_rules! isle_common_prelude_methods {
958
958
i8 :: try_from( val) . ok( )
959
959
}
960
960
961
+ fn i16_as_u16( & mut self , val: i16 ) -> u16 {
962
+ val as u16
963
+ }
964
+
965
+ fn i16_try_from_i32( & mut self , val: i32 ) -> Option <i16 > {
966
+ i16 :: try_from( val) . ok( )
967
+ }
968
+
961
969
fn i16_try_from_u64( & mut self , val: u64 ) -> Option <i16 > {
962
970
i16 :: try_from( val) . ok( )
963
971
}
Original file line number Diff line number Diff line change 142
142
(decl pure partial i8_try_from_u64 (u64) i8)
143
143
(extern constructor i8_try_from_u64 i8_try_from_u64)
144
144
145
+ (decl pure i16_as_u16 (i16) u16)
146
+ (extern constructor i16_as_u16 i16_as_u16)
147
+
145
148
(decl pure partial i16_try_from_u64 (u64) i16)
146
149
(extern constructor i16_try_from_u64 i16_try_from_u64)
147
150
151
+ (decl pure partial i16_try_from_i32 (i16) i32)
152
+ (extern extractor i16_try_from_i32 i16_try_from_i32)
153
+
148
154
(decl pure partial i32_try_from_u64 (u64) i32)
149
155
(extern constructor i32_try_from_u64 i32_try_from_u64)
150
156
151
157
(decl pure u32_as_u64 (u32) u64)
152
158
(extern constructor u32_as_u64 u32_as_u64)
153
159
(convert u32 u64 u32_as_u64)
154
160
155
- (decl i32_as_u32 (u32) i32 )
156
- (extern extractor i32_as_u32 i32_as_u32)
161
+ (decl i32_as_u32 (i32) u32 )
162
+ (extern constructor i32_as_u32 i32_as_u32)
157
163
158
164
(decl pure i32_as_i64 (i32) i64)
159
165
(extern constructor i32_as_i64 i32_as_i64)
Original file line number Diff line number Diff line change
1
+ test compile precise-output
2
+ set unwind_info=false
3
+ set opt_level=speed
4
+ target x86_64
5
+
6
+ function %imul_i16_const_unsigned_but_big(i32) -> i16 {
7
+ block0(v0: i32):
8
+ v3 = imul_imm v0, 0x81111
9
+ v4 = ireduce.i16 v3
10
+ return v4
11
+ }
12
+
13
+ ; VCode:
14
+ ; pushq %rbp
15
+ ; movq %rsp, %rbp
16
+ ; block0:
17
+ ; imulw $0x1111, %di, %ax
18
+ ; movq %rbp, %rsp
19
+ ; popq %rbp
20
+ ; ret
21
+ ;
22
+ ; Disassembled:
23
+ ; block0: ; offset 0x0
24
+ ; pushq %rbp
25
+ ; movq %rsp, %rbp
26
+ ; block1: ; offset 0x4
27
+ ; imulw $0x1111, %di, %ax
28
+ ; movq %rbp, %rsp
29
+ ; popq %rbp
30
+ ; retq
31
+
Original file line number Diff line number Diff line change @@ -284,6 +284,81 @@ block0(v0: i16):
284
284
; popq %rbp
285
285
; retq
286
286
287
+ function %imul_i16_const_negative(i16) -> i16 {
288
+ block0(v0: i16):
289
+ v3 = imul_imm v0, -97
290
+ return v3
291
+ }
292
+
293
+ ; VCode:
294
+ ; pushq %rbp
295
+ ; movq %rsp, %rbp
296
+ ; block0:
297
+ ; imulw $0xff9f, %di, %ax
298
+ ; movq %rbp, %rsp
299
+ ; popq %rbp
300
+ ; ret
301
+ ;
302
+ ; Disassembled:
303
+ ; block0: ; offset 0x0
304
+ ; pushq %rbp
305
+ ; movq %rsp, %rbp
306
+ ; block1: ; offset 0x4
307
+ ; imulw $-0x61, %di, %ax
308
+ ; movq %rbp, %rsp
309
+ ; popq %rbp
310
+ ; retq
311
+
312
+ function %imul_i16_const_unsigned_but_big(i16) -> i16 {
313
+ block0(v0: i16):
314
+ v3 = imul_imm v0, 0x8000
315
+ return v3
316
+ }
317
+
318
+ ; VCode:
319
+ ; pushq %rbp
320
+ ; movq %rsp, %rbp
321
+ ; block0:
322
+ ; imulw $0x8000, %di, %ax
323
+ ; movq %rbp, %rsp
324
+ ; popq %rbp
325
+ ; ret
326
+ ;
327
+ ; Disassembled:
328
+ ; block0: ; offset 0x0
329
+ ; pushq %rbp
330
+ ; movq %rsp, %rbp
331
+ ; block1: ; offset 0x4
332
+ ; imulw $0x8000, %di, %ax
333
+ ; movq %rbp, %rsp
334
+ ; popq %rbp
335
+ ; retq
336
+
337
+ function %imul_i16_const_out_of_bounds(i16) -> i16 {
338
+ block0(v0: i16):
339
+ v3 = imul_imm v0, 0x80000
340
+ return v3
341
+ }
342
+
343
+ ; VCode:
344
+ ; pushq %rbp
345
+ ; movq %rsp, %rbp
346
+ ; block0:
347
+ ; imulw $0x0, %di, %ax
348
+ ; movq %rbp, %rsp
349
+ ; popq %rbp
350
+ ; ret
351
+ ;
352
+ ; Disassembled:
353
+ ; block0: ; offset 0x0
354
+ ; pushq %rbp
355
+ ; movq %rsp, %rbp
356
+ ; block1: ; offset 0x4
357
+ ; imulw $0, %di, %ax
358
+ ; movq %rbp, %rsp
359
+ ; popq %rbp
360
+ ; retq
361
+
287
362
function %imul_i32_const(i32) -> i32{
288
363
block0(v0: i32):
289
364
v3 = imul_imm v0, 97
Original file line number Diff line number Diff line change
1
+ ;; ! target = 'x86_64'
2
+ ;; ! test = 'compile'
3
+
4
+ (module
5
+ (func (export " mul16" ) (param i32 ) (result i32 )
6
+ local.get 0
7
+ i32.const -7937
8
+ i32.mul
9
+ i32.extend16_s
10
+ )
11
+ )
12
+ ;; wasm[0]::function[0]:
13
+ ;; pushq %rbp
14
+ ;; movq %rsp, %rbp
15
+ ;; imulw $0xe0ff, %dx, %dx
16
+ ;; movswl %dx, %eax
17
+ ;; movq %rbp, %rsp
18
+ ;; popq %rbp
19
+ ;; retq
Original file line number Diff line number Diff line change
1
+ (module
2
+ (func (export " mul16" ) (param i32 ) (result i32 )
3
+ local.get 0
4
+ i32.const -7937
5
+ i32.mul
6
+ i32.extend16_s
7
+ )
8
+ )
9
+
10
+ (assert_return (invoke " mul16" (i32.const 100 )) (i32.const -7268 ))
You can’t perform that action at this time.
0 commit comments