riscv64: Add masking for small types when lowering select (#5504)
When lowering `select+icmp` we have an optimization that allows us to avoid materializing the icmp result. We were accidentally not masking the high bits for i8 and i16 in this case. Issue #5498 reported this as an illegal instruction but what was happening there was that the invalid select caused a division by zero.
This commit is contained in:
@@ -615,8 +615,10 @@
|
||||
(gen_select ty (truthy_to_reg cty (normalize_cmp_value cty c)) x y))
|
||||
|
||||
(rule 1
|
||||
(lower (has_type ty (select (icmp cc a b) x y)))
|
||||
(gen_select_reg cc a b x y))
|
||||
(lower (has_type ty (select (icmp cc a b @ (value_type in_ty)) x y)))
|
||||
(let ((a Reg (normalize_cmp_value in_ty a))
|
||||
(b Reg (normalize_cmp_value in_ty b)))
|
||||
(gen_select_reg cc a b x y)))
|
||||
|
||||
;;;;; Rules for `bitselect`;;;;;;;;;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user