This repository has been archived by the owner on Jun 26, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[codegen] legalize imul for 64-bit and 128-bit operands
Add a legalization that legalizes imul.I64 for 32-bit ISAs and imul.I128 for 64-bit (and subsequently 32-bit) ISAs. Refs: bnjbvr/cranelift-x86#4
- Loading branch information
Showing
4 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
test run | ||
target x86_64 haswell | ||
|
||
function %test_imul_i128() -> b1 { | ||
ebb0: | ||
v11 = iconst.i64 0xf2347ac4503f1e24 | ||
v12 = iconst.i64 0x0098fe985354ab06 | ||
v1 = iconcat v11, v12 | ||
v21 = iconst.i64 0xf606ba453589ef89 | ||
v22 = iconst.i64 0x042e1f3054ca7432 | ||
v2 = iconcat v21, v22 | ||
v31 = iconst.i64 0xbe2044b2742ebd44 | ||
v32 = iconst.i64 0xa363ce3b6849f307 | ||
v3 = iconcat v31, v32 | ||
v4 = imul v1, v2 | ||
v5 = icmp eq v3, v4 | ||
return v5 | ||
} | ||
|
||
; run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
; Test the legalization of i128 instructions on x86_64. | ||
test legalizer | ||
target x86_64 haswell | ||
|
||
; regex: V=v\d+ | ||
|
||
function %imul(i128, i128) -> i128 { | ||
ebb0(v1: i128, v2: i128): | ||
v10 = imul v1, v2 | ||
; check: v1 = iconcat $(v1_lsb=$V), $(v1_msb=$V) | ||
; nextln: v2 = iconcat $(v2_lsb=$V), $(v2_msb=$V) | ||
; nextln: $(v10_lsb=$V) = imul $v1_lsb, $v2_lsb | ||
; nextln: $(v11=$V) = imul $v1_msb, $v2_lsb | ||
; nextln: $(v12=$V) = imul $v1_lsb, $v2_msb | ||
; nextln: $(v13=$V) = iadd $v11, $v12 | ||
; nextln: $(v99=$V), $(v14=$V) = x86_umulx $v1_lsb, $v2_lsb | ||
; nextln: $(v10_msb=$V) = iadd $v13, $v14 | ||
; nextln: v10 = iconcat $v10_lsb, $v10_msb | ||
return v10 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters