bytecodealliance / bytecodealliance/wasmtime

riscv64: Merge vector mask generation rules with vector constant generation rules

Open
#6,571 0 comments 1 reaction 0 assignees View on GitHub
cranelift:area:riscv64
Dominant language
Rust
Stars
18.6k
Forks
1.8k
Avg merge
1d 18h
Merged PRs (30d)
126

Description

#### Feature

We currently have separate rules for generating vector masks and vector constants. We should merge these together.

#### Benefit

This would allow us to implement the constant generation logic in a single place, and improve codegen for both use cases.

#### Implementation

Today we have `gen_vec_mask` and `gen_constant`. `gen_constant` takes a `VCodeConstant` and that is not a very flexible interface since it requires us to emit a VCode Constant before using it. As far as I understand that means that those constants would always end up in the constant pool.

We could have `gen_constant` take a byte slice and pattern match based on that. That would allow us to avoid polluting the constant pool, and only materialize the constants there when necessary.

A slight issue with this is that we aren't very good at de-duplicating generated constants, so it would be nice to try and reuse `VCodeConstant`'s when they originate from `vconst`. (Since that means that they have been de-duplicated beforehand)

We could try making a variant of `gen_constant` that is fallible but always emits an optimized lowering that is better than a load to the constant. `gen_constant` could then try that before falling back to loading the de-duplicated constant pool value.

#### Alternatives

Having these as separate rules is an option, however there are some slightly complex constant generation rules that could be beneficial for mask generation which would be nice not to duplicate.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.