Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add backend for 32 bit targets with wide multiplication? #133

Open
newpavlov opened this issue Jul 19, 2021 · 3 comments
Open

Add backend for 32 bit targets with wide multiplication? #133

newpavlov opened this issue Jul 19, 2021 · 3 comments

Comments

@newpavlov
Copy link
Member

Currently polyval (and thus crates built on top of it) uses 32-bit soft backend which was written with targets without wide multiplication in mind. However, this code can be quite inefficient for targets which do support wide multiplication, such as:

  • WASM32: u32s can be extended to 64 bits and multiplied using i64.mul.
  • RISC-V: wide multiplication is implemented by combining MULHU and MUL operations (hardware may fuse them later into a single instruction).

Also it may be worth to add a soft backend for 64-bit targets without wide multiplication? Though right now I can't name a target for which it could be useful.

@tarcieri
Copy link
Member

The current 32-bit backend is largely targeted at things like microcontrollers and should probably be gated on thumb* and other microcontroller targets specifically.

@newpavlov
Copy link
Member Author

According to the comment it may be also useful on i386 targets, no? I guess we can make the 32-bit wide backend default and enable the 32-bit nonwide one only for selected targets.

What are your thoughts about the potential 64-bit nonwide backend?

@tarcieri
Copy link
Member

According to the comment it may be also useful on i386 targets, no?

Wasn't aware Rust even supported those!

What are your thoughts about the potential 64-bit nonwide backend?

I think it's ok to add additional backends (or perhaps decompose the existing backends into separate target-specific codepaths) as long as there's a reasonable performance justification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants