-
Notifications
You must be signed in to change notification settings - Fork 1.7k
cranelift: Fix shifts and implement rotates in interpreter #4519
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| test interpret | ||
| test run | ||
| set enable_llvm_abi_extensions=true | ||
| target aarch64 | ||
|
|
||
1 change: 1 addition & 0 deletions
1
cranelift/filetests/filetests/runtests/i128-shifts-small-types.clif
This file contains hidden or 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 |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| test interpret | ||
| test run | ||
| target aarch64 | ||
| target s390x | ||
|
|
||
This file contains hidden or 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 |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| test interpret | ||
| test run | ||
| set enable_llvm_abi_extensions=true | ||
| target aarch64 | ||
|
|
||
This file contains hidden or 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,243 @@ | ||
| test interpret | ||
| test run | ||
| target aarch64 | ||
| target x86_64 | ||
| target s390x | ||
|
|
||
|
|
||
| function %rotl_i64_i64(i64, i64) -> i64 { | ||
| block0(v0: i64, v1: i64): | ||
| v2 = rotl.i64 v0, v1 | ||
| return v2 | ||
| } | ||
| ; run: %rotl_i64_i64(0xe0000000_00000000, 0) == 0xe0000000_00000000 | ||
| ; run: %rotl_i64_i64(0xe0000000_00000000, 1) == 0xc0000000_00000001 | ||
| ; run: %rotl_i64_i64(0xe000000f_0000000f, 0) == 0xe000000f_0000000f | ||
| ; run: %rotl_i64_i64(0xe000000f_0000000f, 4) == 0x000000f0_000000fe | ||
| ; run: %rotl_i64_i64(0xe0000000_00000004, 64) == 0xe0000000_00000004 | ||
| ; run: %rotl_i64_i64(0xe0000000_00000004, 65) == 0xc0000000_00000009 | ||
| ; run: %rotl_i64_i64(0xe0000000_00000004, 66) == 0x80000000_00000013 | ||
| ; run: %rotl_i64_i64(0xe0000000_00000004, 257) == 0xc0000000_00000009 | ||
|
|
||
| function %rotl_i64_i32(i64, i32) -> i64 { | ||
| block0(v0: i64, v1: i32): | ||
| v2 = rotl.i64 v0, v1 | ||
| return v2 | ||
| } | ||
| ; run: %rotl_i64_i32(0xe0000000_00000000, 0) == 0xe0000000_00000000 | ||
| ; run: %rotl_i64_i32(0xe0000000_00000000, 1) == 0xc0000000_00000001 | ||
| ; run: %rotl_i64_i32(0xe000000f_0000000f, 0) == 0xe000000f_0000000f | ||
| ; run: %rotl_i64_i32(0xe000000f_0000000f, 4) == 0x000000f0_000000fe | ||
| ; run: %rotl_i64_i32(0xe0000000_00000004, 64) == 0xe0000000_00000004 | ||
| ; run: %rotl_i64_i32(0xe0000000_00000004, 65) == 0xc0000000_00000009 | ||
| ; run: %rotl_i64_i32(0xe0000000_00000004, 66) == 0x80000000_00000013 | ||
| ; run: %rotl_i64_i32(0xe0000000_00000004, 257) == 0xc0000000_00000009 | ||
|
|
||
| function %rotl_i64_i16(i64, i16) -> i64 { | ||
| block0(v0: i64, v1: i16): | ||
| v2 = rotl.i64 v0, v1 | ||
| return v2 | ||
| } | ||
| ; run: %rotl_i64_i16(0xe0000000_00000000, 0) == 0xe0000000_00000000 | ||
| ; run: %rotl_i64_i16(0xe0000000_00000000, 1) == 0xc0000000_00000001 | ||
| ; run: %rotl_i64_i16(0xe000000f_0000000f, 0) == 0xe000000f_0000000f | ||
| ; run: %rotl_i64_i16(0xe000000f_0000000f, 4) == 0x000000f0_000000fe | ||
| ; run: %rotl_i64_i16(0xe0000000_00000004, 64) == 0xe0000000_00000004 | ||
| ; run: %rotl_i64_i16(0xe0000000_00000004, 65) == 0xc0000000_00000009 | ||
| ; run: %rotl_i64_i16(0xe0000000_00000004, 66) == 0x80000000_00000013 | ||
| ; run: %rotl_i64_i16(0xe0000000_00000004, 257) == 0xc0000000_00000009 | ||
|
|
||
| function %rotl_i64_i8(i64, i8) -> i64 { | ||
| block0(v0: i64, v1: i8): | ||
| v2 = rotl.i64 v0, v1 | ||
| return v2 | ||
| } | ||
| ; run: %rotl_i64_i8(0xe0000000_00000000, 0) == 0xe0000000_00000000 | ||
| ; run: %rotl_i64_i8(0xe0000000_00000000, 1) == 0xc0000000_00000001 | ||
| ; run: %rotl_i64_i8(0xe000000f_0000000f, 0) == 0xe000000f_0000000f | ||
| ; run: %rotl_i64_i8(0xe000000f_0000000f, 4) == 0x000000f0_000000fe | ||
| ; run: %rotl_i64_i8(0xe0000000_00000004, 64) == 0xe0000000_00000004 | ||
| ; run: %rotl_i64_i8(0xe0000000_00000004, 65) == 0xc0000000_00000009 | ||
| ; run: %rotl_i64_i8(0xe0000000_00000004, 66) == 0x80000000_00000013 | ||
|
|
||
|
|
||
| function %rotl_i32_i64(i32, i64) -> i32 { | ||
| block0(v0: i32, v1: i64): | ||
| v2 = rotl.i32 v0, v1 | ||
| return v2 | ||
| } | ||
| ; run: %rotl_i32_i64(0xe0000000, 0) == 0xe0000000 | ||
| ; run: %rotl_i32_i64(0xe0000000, 1) == 0xc0000001 | ||
| ; run: %rotl_i32_i64(0xe00f000f, 0) == 0xe00f000f | ||
| ; run: %rotl_i32_i64(0xe00f000f, 4) == 0x00f000fe | ||
| ; run: %rotl_i32_i64(0xe0000004, 64) == 0xe0000004 | ||
| ; run: %rotl_i32_i64(0xe0000004, 65) == 0xc0000009 | ||
| ; run: %rotl_i32_i64(0xe0000004, 66) == 0x80000013 | ||
| ; run: %rotl_i32_i64(0xe0000004, 257) == 0xc0000009 | ||
|
|
||
| function %rotl_i32_i32(i32, i32) -> i32 { | ||
| block0(v0: i32, v1: i32): | ||
| v2 = rotl.i32 v0, v1 | ||
| return v2 | ||
| } | ||
| ; run: %rotl_i32_i32(0xe0000000, 0) == 0xe0000000 | ||
| ; run: %rotl_i32_i32(0xe0000000, 1) == 0xc0000001 | ||
| ; run: %rotl_i32_i32(0xe00f000f, 0) == 0xe00f000f | ||
| ; run: %rotl_i32_i32(0xe00f000f, 4) == 0x00f000fe | ||
| ; run: %rotl_i32_i32(0xe0000004, 64) == 0xe0000004 | ||
| ; run: %rotl_i32_i32(0xe0000004, 65) == 0xc0000009 | ||
| ; run: %rotl_i32_i32(0xe0000004, 66) == 0x80000013 | ||
| ; run: %rotl_i32_i32(0xe0000004, 257) == 0xc0000009 | ||
|
|
||
| function %rotl_i32_i16(i32, i16) -> i32 { | ||
| block0(v0: i32, v1: i16): | ||
| v2 = rotl.i32 v0, v1 | ||
| return v2 | ||
| } | ||
| ; run: %rotl_i32_i16(0xe0000000, 0) == 0xe0000000 | ||
| ; run: %rotl_i32_i16(0xe0000000, 1) == 0xc0000001 | ||
| ; run: %rotl_i32_i16(0xe00f000f, 0) == 0xe00f000f | ||
| ; run: %rotl_i32_i16(0xe00f000f, 4) == 0x00f000fe | ||
| ; run: %rotl_i32_i16(0xe0000004, 64) == 0xe0000004 | ||
| ; run: %rotl_i32_i16(0xe0000004, 65) == 0xc0000009 | ||
| ; run: %rotl_i32_i16(0xe0000004, 66) == 0x80000013 | ||
| ; run: %rotl_i32_i16(0xe0000004, 257) == 0xc0000009 | ||
|
|
||
| function %rotl_i32_i8(i32, i8) -> i32 { | ||
| block0(v0: i32, v1: i8): | ||
| v2 = rotl.i32 v0, v1 | ||
| return v2 | ||
| } | ||
| ; run: %rotl_i32_i8(0xe0000000, 0) == 0xe0000000 | ||
| ; run: %rotl_i32_i8(0xe0000000, 1) == 0xc0000001 | ||
| ; run: %rotl_i32_i8(0xe00f000f, 0) == 0xe00f000f | ||
| ; run: %rotl_i32_i8(0xe00f000f, 4) == 0x00f000fe | ||
| ; run: %rotl_i32_i8(0xe0000004, 64) == 0xe0000004 | ||
| ; run: %rotl_i32_i8(0xe0000004, 65) == 0xc0000009 | ||
| ; run: %rotl_i32_i8(0xe0000004, 66) == 0x80000013 | ||
|
|
||
|
|
||
| function %rotl_i16_i64(i16, i64) -> i16 { | ||
| block0(v0: i16, v1: i64): | ||
| v2 = rotl.i16 v0, v1 | ||
| return v2 | ||
| } | ||
| ; run: %rotl_i16_i64(0xe000, 0) == 0xe000 | ||
| ; run: %rotl_i16_i64(0xe000, 1) == 0xc001 | ||
| ; run: %rotl_i16_i64(0xef0f, 0) == 0xef0f | ||
| ; run: %rotl_i16_i64(0xef0f, 4) == 0xf0fe | ||
| ; run: %rotl_i16_i64(0xe004, 64) == 0xe004 | ||
| ; run: %rotl_i16_i64(0xe004, 65) == 0xc009 | ||
| ; run: %rotl_i16_i64(0xe004, 66) == 0x8013 | ||
| ; run: %rotl_i16_i64(0xe004, 257) == 0xc009 | ||
|
|
||
| function %rotl_i16_i32(i16, i32) -> i16 { | ||
| block0(v0: i16, v1: i32): | ||
| v2 = rotl.i16 v0, v1 | ||
| return v2 | ||
| } | ||
| ; run: %rotl_i16_i32(0xe000, 0) == 0xe000 | ||
| ; run: %rotl_i16_i32(0xe000, 1) == 0xc001 | ||
| ; run: %rotl_i16_i32(0xef0f, 0) == 0xef0f | ||
| ; run: %rotl_i16_i32(0xef0f, 4) == 0xf0fe | ||
| ; run: %rotl_i16_i32(0xe004, 64) == 0xe004 | ||
| ; run: %rotl_i16_i32(0xe004, 65) == 0xc009 | ||
| ; run: %rotl_i16_i32(0xe004, 66) == 0x8013 | ||
| ; run: %rotl_i16_i32(0xe004, 257) == 0xc009 | ||
|
|
||
| function %rotl_i16_i16(i16, i16) -> i16 { | ||
| block0(v0: i16, v1: i16): | ||
| v2 = rotl.i16 v0, v1 | ||
| return v2 | ||
| } | ||
| ; run: %rotl_i16_i16(0xe000, 0) == 0xe000 | ||
| ; run: %rotl_i16_i16(0xe000, 1) == 0xc001 | ||
| ; run: %rotl_i16_i16(0xef0f, 0) == 0xef0f | ||
| ; run: %rotl_i16_i16(0xef0f, 4) == 0xf0fe | ||
| ; run: %rotl_i16_i16(0xe004, 64) == 0xe004 | ||
| ; run: %rotl_i16_i16(0xe004, 65) == 0xc009 | ||
| ; run: %rotl_i16_i16(0xe004, 66) == 0x8013 | ||
| ; run: %rotl_i16_i16(0xe004, 257) == 0xc009 | ||
|
|
||
| function %rotl_i16_i8(i16, i8) -> i16 { | ||
| block0(v0: i16, v1: i8): | ||
| v2 = rotl.i16 v0, v1 | ||
| return v2 | ||
| } | ||
| ; run: %rotl_i16_i8(0xe000, 0) == 0xe000 | ||
| ; run: %rotl_i16_i8(0xe000, 1) == 0xc001 | ||
| ; run: %rotl_i16_i8(0xef0f, 0) == 0xef0f | ||
| ; run: %rotl_i16_i8(0xef0f, 4) == 0xf0fe | ||
| ; run: %rotl_i16_i8(0xe004, 64) == 0xe004 | ||
| ; run: %rotl_i16_i8(0xe004, 65) == 0xc009 | ||
| ; run: %rotl_i16_i8(0xe004, 66) == 0x8013 | ||
|
|
||
|
|
||
| function %rotl_i8_i64(i8, i64) -> i8 { | ||
| block0(v0: i8, v1: i64): | ||
| v2 = rotl.i8 v0, v1 | ||
| return v2 | ||
| } | ||
| ; run: %rotl_i8_i64(0xe0, 0) == 0xe0 | ||
| ; run: %rotl_i8_i64(0xe0, 1) == 0xc1 | ||
| ; run: %rotl_i8_i64(0xef, 0) == 0xef | ||
| ; run: %rotl_i8_i64(0xef, 4) == 0xfe | ||
| ; run: %rotl_i8_i64(0xe4, 64) == 0xe4 | ||
| ; run: %rotl_i8_i64(0xe4, 65) == 0xc9 | ||
| ; run: %rotl_i8_i64(0xe4, 66) == 0x93 | ||
| ; run: %rotl_i8_i64(0xe4, 257) == 0xc9 | ||
|
|
||
| function %rotl_i8_i32(i8, i32) -> i8 { | ||
| block0(v0: i8, v1: i32): | ||
| v2 = rotl.i8 v0, v1 | ||
| return v2 | ||
| } | ||
| ; run: %rotl_i8_i32(0xe0, 0) == 0xe0 | ||
| ; run: %rotl_i8_i32(0xe0, 1) == 0xc1 | ||
| ; run: %rotl_i8_i32(0xef, 0) == 0xef | ||
| ; run: %rotl_i8_i32(0xef, 4) == 0xfe | ||
| ; run: %rotl_i8_i32(0xe4, 64) == 0xe4 | ||
| ; run: %rotl_i8_i32(0xe4, 65) == 0xc9 | ||
| ; run: %rotl_i8_i32(0xe4, 66) == 0x93 | ||
| ; run: %rotl_i8_i32(0xe4, 257) == 0xc9 | ||
|
|
||
| function %rotl_i8_i16(i8, i16) -> i8 { | ||
| block0(v0: i8, v1: i16): | ||
| v2 = rotl.i8 v0, v1 | ||
| return v2 | ||
| } | ||
| ; run: %rotl_i8_i16(0xe0, 0) == 0xe0 | ||
| ; run: %rotl_i8_i16(0xe0, 1) == 0xc1 | ||
| ; run: %rotl_i8_i16(0xef, 0) == 0xef | ||
| ; run: %rotl_i8_i16(0xef, 4) == 0xfe | ||
| ; run: %rotl_i8_i16(0xe4, 64) == 0xe4 | ||
| ; run: %rotl_i8_i16(0xe4, 65) == 0xc9 | ||
| ; run: %rotl_i8_i16(0xe4, 66) == 0x93 | ||
| ; run: %rotl_i8_i16(0xe4, 257) == 0xc9 | ||
|
|
||
| function %rotl_i8_i8(i8, i8) -> i8 { | ||
| block0(v0: i8, v1: i8): | ||
| v2 = rotl.i8 v0, v1 | ||
| return v2 | ||
| } | ||
| ; run: %rotl_i8_i8(0xe0, 0) == 0xe0 | ||
| ; run: %rotl_i8_i8(0xe0, 1) == 0xc1 | ||
| ; run: %rotl_i8_i8(0xef, 0) == 0xef | ||
| ; run: %rotl_i8_i8(0xef, 4) == 0xfe | ||
| ; run: %rotl_i8_i8(0xe4, 64) == 0xe4 | ||
| ; run: %rotl_i8_i8(0xe4, 65) == 0xc9 | ||
| ; run: %rotl_i8_i8(0xe4, 66) == 0x93 | ||
|
|
||
|
|
||
|
|
||
| ;; This is a regression test for rotates on x64 | ||
| ;; See: https://github.com/bytecodealliance/wasmtime/pull/3610 | ||
| function %rotl_i8_const_37(i8) -> i8 { | ||
| block0(v0: i8): | ||
| v1 = iconst.i8 37 | ||
| v2 = rotl.i8 v0, v1 | ||
| return v2 | ||
| } | ||
| ; run: %rotl_i8_const_37(0x00) == 0x00 | ||
| ; run: %rotl_i8_const_37(0x01) == 0x20 | ||
| ; run: %rotl_i8_const_37(0x12) == 0x42 | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really appreciate that you not only tracked down where these particular tests came from, but also left a link here in case anybody else wonders!