[Cranelift] add type-aware imm64 constant folding operations#12826
[Cranelift] add type-aware imm64 constant folding operations#12826fitzgen merged 7 commits intobytecodealliance:mainfrom
Conversation
a10f67c to
2722fd3
Compare
This makes sense to me. I wonder if we can or should generate and/or enumerate these |
|
@fitzgen I think we should implement |
|
Makes sense to me 👍 |
a04de21 to
e652a32
Compare
|
Subscribe to Label ActionDetailsThis issue or pull request has been labeled: "cranelift", "isle"Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
e652a32 to
e70124e
Compare
|
@fitzgen conflicts are now resolved, and the filetests are re-blessed (register numbering was changed). thanks! |
This is a followup of #12764
I'm adding rules that perform constant foldings. However, currently, Cranelift mainly uses
u64/i64_*operations that are meta-generated by https://github.com/bytecodealliance/wasmtime/blob/main/cranelift/codegen/meta/src/gen_isle.rsHowever, those u64/i64 operations are not aware bitwidth specified by type specifier (usually captured by
ty) and signedness of a constant. Thus one cannot easily handle overflow, shift/rotation crossing bitwidth boundaries. Therefore, one has to carefully reason about the bitwidth boundary conditions, but can occasionally fail to write a correct rule. On the other hand,imm64-based constant operations perform computations considering those bitwidth-related semantics. This advantage is observed in the current implementation ofimm64_sdivas it requires the precise view of Cranelift constants to correctly perform "signedness"-aware computation. In addition, usingimm64-based constant operations, the implementation (writingsimplifyrules and more) is more straightforward and convenient since the primary representation of constants in Cranelift isimm64. (u64/i64are Rust representation of constant literals).For these reasons, I'm proposing that we should prioritize
imm64-based approach rather thanuN/iNone to make it easier to develop safe constant folding operations. This PR prepares suchimm64operations for further inclusion of various constant expressions.