forked from bytecodealliance/wasmtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cranelift: Reassociate constants out of nested shifts (bytecodeallian…
…ce#7450) This allows for more constant propagation. Co-authored-by: Trevor Elliott <telliott@fastly.com>
- Loading branch information
Showing
2 changed files
with
51 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
41 changes: 41 additions & 0 deletions
41
cranelift/filetests/filetests/egraph/reassociate-constants-in-shifts.clif
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,41 @@ | ||
test optimize | ||
set opt_level=speed | ||
target x86_64 | ||
|
||
;; Test egraph rewrite rules that reassociate constants out of nested shifts. | ||
|
||
function %a(i32) -> i32 { | ||
block0(v0: i32): | ||
v1 = iconst.i32 1 | ||
v2 = ishl v1, v0 | ||
v3 = iconst.i32 2 | ||
v4 = ishl v2, v3 | ||
return v4 | ||
; check: v6 = iconst.i32 4 | ||
; nextln: v7 = ishl v6, v0 | ||
; check: return v7 | ||
} | ||
|
||
function %b(i32) -> i32 { | ||
block0(v0: i32): | ||
v1 = iconst.i32 8 | ||
v2 = ushr v1, v0 | ||
v3 = iconst.i32 2 | ||
v4 = ushr v2, v3 | ||
return v4 | ||
; check: v3 = iconst.i32 2 | ||
; nextln: v6 = ushr v3, v0 | ||
; check: return v6 | ||
} | ||
|
||
function %c(i32) -> i32 { | ||
block0(v0: i32): | ||
v1 = iconst.i32 8 | ||
v2 = sshr v1, v0 | ||
v3 = iconst.i32 2 | ||
v4 = sshr v2, v3 | ||
return v4 | ||
; check: v3 = iconst.i32 2 | ||
; nextln: v6 = sshr v3, v0 | ||
; check: return v6 | ||
} |