Cranelift: constant propagate shifts (#5671)

Thanks to Souper for pointing out we weren't doing this!
This commit is contained in:
Nick Fitzgerald
2023-01-31 12:06:53 -08:00
committed by GitHub
parent 10fcd14287
commit 7aa240e0f2
4 changed files with 80 additions and 0 deletions

View File

@@ -41,3 +41,35 @@ block0(v1: i8):
; check: v3 = iconst.i8 0
; check: return v3
function %ishl() -> i8 {
block0:
v0 = iconst.i8 1
v1 = iconst.i8 2
v2 = ishl v0, v1
return v2
}
; check: v3 = iconst.i8 4
; check: return v3
function %ushr() -> i8 {
block0:
v0 = iconst.i8 -1
v1 = iconst.i8 2
v2 = ushr v0, v1
return v2
}
; check: v3 = iconst.i8 63
; check: return v3
function %sshr() -> i8 {
block0:
v0 = iconst.i8 0xf0
v1 = iconst.i8 2
v2 = sshr v0, v1
return v2
}
; check: v3 = iconst.i8 -4
; check: return v3