afonso360 opened issue #7189:
:wave: Hey,
This is a fairly simple improvement. Cranelift's
scalar_to_vectorinstruction grabs a scalar value and places it at the bottom of a vector register.We translate this into the
vmerge.vxminstruction in the RISC-V backend.This is all fairly ok, but we don't have a rule to match the
vmerge.viminstruction that can instead place an immediate value instead of a register.Implementing this should be fairly simple, we can create a rule similar to the existing ones but using a
imm5_from_valueextractror:(rule 2 (lower (has_type (ty_vec_fits_in_register ty) (scalar_to_vector (imm5_from_value x))))This
imm5_from_valueextractor doesn't exist yet, but we already have an equivalent in thereplicated_imm5extractor. It should be fairly easy to extract that into it's own separate extractor for use in this new rule.See the existing
uimm5_from_valueextractor for help.If anyone needs help working on this issue let me know!
afonso360 added the cranelift:E-easy label to Issue #7189.
afonso360 added the cranelift:area:riscv64 label to Issue #7189.
afonso360 edited issue #7189:
:wave: Hey,
This is a fairly simple improvement. Cranelift's
scalar_to_vectorinstruction grabs a scalar value and places it at the bottom of a vector register.We translate this into the
vmerge.vxminstruction in the RISC-V backend.This is all fairly ok, but we don't have a rule to match the
vmerge.viminstruction that can instead place an immediate value instead of a register.Implementing this should be fairly simple, we can create a rule similar to the existing ones but using a
imm5_from_valueextractror:(rule 2 (lower (has_type (ty_vec_fits_in_register ty) (scalar_to_vector (imm5_from_value x))))This
imm5_from_valueextractor doesn't exist yet, but we already have an equivalent in thereplicated_imm5extractor. It should be fairly easy to extract that into it's own separate extractor for use in this new rule.See the existing
uimm5_from_valueextractor for help.If anyone needs help working on this issue let me know!
afonso360 edited issue #7189:
:wave: Hey,
This is a fairly simple improvement. Cranelift's
scalar_to_vectorinstruction grabs a scalar value and places it at the bottom of a vector register.We translate this into the
vmerge.vxminstruction in the RISC-V backend.This is all fairly ok, but we don't have a rule to match the
vmerge.viminstruction that can place an immediate value instead of a register.Implementing this should be fairly simple, we can create a rule similar to the existing ones but using a
imm5_from_valueextractror:(rule 2 (lower (has_type (ty_vec_fits_in_register ty) (scalar_to_vector (imm5_from_value x))))This
imm5_from_valueextractor doesn't exist yet, but we already have an equivalent in thereplicated_imm5extractor. It should be fairly easy to extract that into it's own separate extractor for use in this new rule.See the existing
uimm5_from_valueextractor for help.If anyone needs help working on this issue let me know!
BieVic commented on issue #7189:
Hey! I'm fairly new to Cranelift but would like to give it a try.
afonso360 commented on issue #7189:
Awesome :tada: Let me know if you need any help getting started!
afonso360 closed issue #7189:
:wave: Hey,
This is a fairly simple improvement. Cranelift's
scalar_to_vectorinstruction grabs a scalar value and places it at the bottom of a vector register.We translate this into the
vmerge.vxminstruction in the RISC-V backend.This is all fairly ok, but we don't have a rule to match the
vmerge.viminstruction that can place an immediate value instead of a register.Implementing this should be fairly simple, we can create a rule similar to the existing ones but using a
imm5_from_valueextractror:(rule 2 (lower (has_type (ty_vec_fits_in_register ty) (scalar_to_vector (imm5_from_value x))))This
imm5_from_valueextractor doesn't exist yet, but we already have an equivalent in thereplicated_imm5extractor. It should be fairly easy to extract that into it's own separate extractor for use in this new rule.See the existing
uimm5_from_valueextractor for help.If anyone needs help working on this issue let me know!
Last updated: Dec 13 2025 at 19:03 UTC