Consider providing casting primops between differently sized ints/words as primops.
Currently the conversion primops are represented by a limited list of primops like Word64ToWordOp
.
In general we only have cast between:
- Sized Int/Word <-> machine Int/Word.
- Sized Int/Word <-> Sized Word/Int, where sizes are the same before and after.
Unless I missed something this means casting e.g. from W64 to W8 requires two casts in Core/Stg. First from W64 to W, then from W to W8. This will eventually compile away to just one conversion in the backend, but I wonder if it's worth making all these conversions expressible in the haskell primops directly.
Either by just adding the missing casts to the current setup, or refactoring these casting PrimOps to rather be WordToWord Width Width
internally.
I think it's about 70 primops which would need to be added which is quite a bit. But given that we already have almost 700 primops perhaps it's likely not a big problem to do so.