Skip to content

Conversation

@MaxGraey
Copy link
Contributor

Reminder by constant should have slightly more cost due to x % C usually lower to
x - C * (x * M' >> C")
while div by const to:
x * M' >> C"
on VM engines.

@kripken
Copy link
Member

kripken commented Oct 29, 2021

I think we should have a methodology for deciding on these constants before we change any. Ah, I see you recently opened WebAssembly/design#1434 ... that would really be useful to get.

I don't have time to look into this myself. But I'd try to find existing documentation, either in compilers or for CPUs. Failing that, actually running microbenchmarks would be useful.

@MaxGraey
Copy link
Contributor Author

I think we should have a methodology for deciding on these constants before we change any

Yes, I agree. That's why I opened design issue. But it seems that not everyone is interested in taking the time to do it. In the meantime, I just look at what the godbolt tools for specific operation codegen and specify the costs. This is the best we can do right now, because I'm afraid a standardized costs table won't appear anytime soon, if ever.

@kripken
Copy link
Member

kripken commented Nov 5, 2021

Another option aside from godbolt is to find where LLVM has such a table - I assume it must have one somewhere?

@MaxGraey
Copy link
Contributor Author

MaxGraey commented Nov 5, 2021

Another option aside from godbolt is to find where LLVM has such a table - I assume it must have one somewhere?

I was checked the cost table from LLVM. Unfortunately it is not very accurate and less oriented to modern platforms. In addition, it's formed empirically as well

@MaxGraey
Copy link
Contributor Author

MaxGraey commented Nov 5, 2021

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

Successfully merging this pull request may close these issues.

2 participants