Fix narrow_icmp_imm (#1343)
This commit is contained in:
committed by
Benjamin Bouvier
parent
175b9641e0
commit
ae6ba1e58c
@@ -702,7 +702,7 @@ fn narrow_icmp_imm(
|
|||||||
|
|
||||||
let imm_low = pos
|
let imm_low = pos
|
||||||
.ins()
|
.ins()
|
||||||
.iconst(ty_half, imm & (1u128 << (ty_half.bits() - 1)) as i64);
|
.iconst(ty_half, imm & ((1u128 << ty_half.bits()) - 1) as i64);
|
||||||
let imm_high = pos
|
let imm_high = pos
|
||||||
.ins()
|
.ins()
|
||||||
.iconst(ty_half, imm.wrapping_shr(ty_half.bits().into()));
|
.iconst(ty_half, imm.wrapping_shr(ty_half.bits().into()));
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
test legalizer
|
||||||
|
target riscv32
|
||||||
|
|
||||||
|
; regex: V=v\d+
|
||||||
|
|
||||||
|
function %icmp_imm_eq(i64) -> b1 {
|
||||||
|
ebb0(v0: i64):
|
||||||
|
v1 = icmp_imm eq v0, 0x20202020_10101010
|
||||||
|
return v1
|
||||||
|
}
|
||||||
|
; check: ebb0($(v0l=$V): i32, $(v0h=$V): i32, $(link=$V): i32):
|
||||||
|
; nextln: $(v2l=$V) -> $(v0l)
|
||||||
|
; nextln: $(v2h=$V) -> $(v0h)
|
||||||
|
; nextln: v0 = iconcat $(v0l), $(v0h)
|
||||||
|
; nextln: $(imm_low=$V) = iconst.i32 0x1010_1010
|
||||||
|
; nextln: $(imm_high=$V) = iconst.i32 0x2020_2020
|
||||||
|
; nextln: $(v3=$V) = icmp eq $(v2l), $(imm_low)
|
||||||
|
; nextln: $(v4=$V) = icmp eq $(v2h), $(imm_high)
|
||||||
|
; nextln: v1 = band $(v3), $(v4)
|
||||||
|
; nextln: return v1, $(link)
|
||||||
|
|
||||||
|
function %icmp_imm_ne(i64) -> b1 {
|
||||||
|
ebb0(v0: i64):
|
||||||
|
v1 = icmp_imm ne v0, 0x33333333_44444444
|
||||||
|
return v1
|
||||||
|
}
|
||||||
|
; check: ebb0($(v0l=$V): i32, $(v0h=$V): i32, $(link=$V): i32):
|
||||||
|
; nextln: $(v2l=$V) -> $(v0l)
|
||||||
|
; nextln: $(v2h=$V) -> $(v0h)
|
||||||
|
; nextln: v0 = iconcat $(v0l), $(v0h)
|
||||||
|
; nextln: $(imm_low=$V) = iconst.i32 0x4444_4444
|
||||||
|
; nextln: $(imm_high=$V) = iconst.i32 0x3333_3333
|
||||||
|
; nextln: $(v3=$V) = icmp ne $(v2l), $(imm_low)
|
||||||
|
; nextln: $(v4=$V) = icmp ne $(v2h), $(imm_high)
|
||||||
|
; nextln: v1 = bor $(v3), $(v4)
|
||||||
|
; nextln: return v1, $(link)
|
||||||
|
|
||||||
|
function %icmp_imm_sge(i64) -> b1 {
|
||||||
|
ebb0(v0: i64):
|
||||||
|
v1 = icmp_imm sge v0, 0x01020304_05060708
|
||||||
|
return v1
|
||||||
|
}
|
||||||
|
; check: ebb0($(v0l=$V): i32, $(v0h=$V): i32, $(link=$V): i32):
|
||||||
|
; nextln: $(v2l=$V) -> $(v0l)
|
||||||
|
; nextln: $(v2h=$V) -> $(v0h)
|
||||||
|
; nextln: v0 = iconcat $(v0l), $(v0h)
|
||||||
|
; nextln: $(imm_low=$V) = iconst.i32 0x0506_0708
|
||||||
|
; nextln: $(imm_high=$V) = iconst.i32 0x0102_0304
|
||||||
|
; nextln: $(v3=$V) = icmp sgt $(v2h), $(imm_high)
|
||||||
|
; nextln: $(v4=$V) = icmp slt $(v2h), $(imm_high)
|
||||||
|
; nextln: $(v5=$V) = icmp uge $(v2l), $(imm_low)
|
||||||
|
; nextln: $(v6=$V) = bnot $v4
|
||||||
|
; nextln: $(v7=$V) = band $v6, $v5
|
||||||
|
; nextln: v1 = bor $(v3), $(v7)
|
||||||
|
; nextln: return v1, $(link)
|
||||||
Reference in New Issue
Block a user