Cranelift: Correctly wrap shifts in constant propagation (#5695)

Fixes #5690
Fixes #5696

Co-authored-by: Jamey Sharp <jsharp@fastly.com>
This commit is contained in:
Nick Fitzgerald
2023-02-02 16:12:57 -08:00
committed by GitHub
parent fd67ccf9cd
commit 72c8513411
10 changed files with 176 additions and 35 deletions

View File

@@ -87,6 +87,17 @@ block0(v0: i64):
; return v5
}
function %signed_shift_right_shift_left_i8_mask_rhs(i8) -> i8 {
block0(v0: i8):
v1 = iconst.i8 0xf5
v2 = sshr v0, v1
v3 = ishl v2, v1
return v3
; check: v4 = iconst.i8 224
; check: v5 = band v0, v4
; return v5
}
function %or_and_y_with_not_y_i8(i8, i8) -> i8 {
block0(v0: i8, v1: i8):
v2 = band v0, v1

View File

@@ -34,6 +34,28 @@ block0:
; check: v3 = iconst.i8 4
; check: return v3
function %ishl_i8_i16() -> i8 {
block0:
v0 = iconst.i8 1
v1 = iconst.i16 0xf2
v2 = ishl v0, v1
return v2
}
; check: v3 = iconst.i8 4
; check: return v3
function %ishl_i16_i8() -> i16 {
block0:
v0 = iconst.i16 1
v1 = iconst.i8 0xf2
v2 = ishl v0, v1
return v2
}
; check: v3 = iconst.i16 4
; check: return v3
function %ushr() -> i8 {
block0:
v0 = iconst.i8 -1
@@ -45,6 +67,28 @@ block0:
; check: v3 = iconst.i8 63
; check: return v3
function %ushr_i8_i16() -> i8 {
block0:
v0 = iconst.i8 -1
v1 = iconst.i16 0xf2
v2 = ushr v0, v1
return v2
}
; check: v3 = iconst.i8 63
; check: return v3
function %ushr_i16_i8() -> i16 {
block0:
v0 = iconst.i16 -1
v1 = iconst.i8 0xf2
v2 = ushr v0, v1
return v2
}
; check: v3 = iconst.i16 0x3fff
; check: return v3
function %sshr() -> i8 {
block0:
v0 = iconst.i8 0xf0
@@ -53,7 +97,29 @@ block0:
return v2
}
; check: v3 = iconst.i8 -4
; check: v3 = iconst.i8 252
; check: return v3
function %sshr_i8_i16() -> i8 {
block0:
v0 = iconst.i8 0xf0
v1 = iconst.i16 0xf2
v2 = sshr v0, v1
return v2
}
; check: v3 = iconst.i8 252
; check: return v3
function %sshr_i16_i8() -> i16 {
block0:
v0 = iconst.i16 0xfff0
v1 = iconst.i8 0xf2
v2 = sshr v0, v1
return v2
}
; check: v3 = iconst.i16 0xfffc
; check: return v3
function %icmp_eq_i32() -> i8 {