Implement more Math LLVM intrinsics #16578
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds all missing Math/MathF intrinsics except:
Round(float)
-- is not yet implemented (should not use high levelllvm.round.f32
)Asin
,Acos
, etcMath.Sign
I reorganized them a bit (grouped by parameters count and type) I suspect it's easier to look at the change like this: https://github.com/EgorBo/mono/blob/llvm-math-more2/mono/mini/intrinsics.c#L108-L245
Also, some opcodes use
OP_XXXF
for float andOP_XXX
for double, the others useOP_RXXX
for float andOP_FXXX
for double so it was difficult to make it consistent (I didn't rename the existing ones).Test:
Codegen:
LLVM IR (fast math): https://gist.github.com/EgorBo/219c5979272e2079b0d063ffbb7b7e19
ASM (fast math): https://gist.github.com/EgorBo/2cec0d58d00a3b19132c1d27962319c3
Some funny optimizations (with
--ffast-math
):