8-bit and 16-bit arithmetic
Ben Gamari
ben at smart-cactus.org
Thu Oct 28 21:37:52 UTC 2021
Norman Ramsey <nr at cs.tufts.edu> writes:
> On x86, GHC can translate 8-bit and 16-bit operations directly
> into the 8-bit and 16-bit machine instructions that the hardware
> supports. But there are other platforms on which the smallest
> unit of arithmetic may be 32 or even 64 bits. Is there a central
> module in GHC that can take care of rewriting 8-bit and 16-bit operations
> into 32-bit or 64-bit operations? Or is each back end on its own
> for this?
>
> (One of my students did some nice work on implementing this transformation
> with a minimal set of sign-extension and zero-extension operations:
> https://www.cs.tufts.edu/~nr/pubs/widen.pdf.)
>
As Carter indicated, this is currently done on a per-backend basis. This
could indeed probably be consolidated, although we would want to make
sure that in so doing we do not leave easy money on the table: It seems
plausible to me that the backend may be able to generate better code
than a naive lowering to wide arithmetic might otherwise generate.
Cheers,
- Ben
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 905 bytes
Desc: not available
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20211028/c06e579a/attachment.sig>
More information about the ghc-devs
mailing list