This is an archive of the discontinued LLVM Phabricator instance.

IR: Add llvm.exp10 intrinsic
ClosedPublic

Authored by arsenm on Aug 14 2023, 7:29 AM.

Details

Summary

We currently have log, log2, log10, exp and exp2 intrinsics. Add
exp10 to fix this asymmetry. AMDGPU already has most of the code for
f32 exp10 expansion implemented alongside exp, so the current
implementation is duplicating nearly identical effort between the
compiler and library which is inconvenient.

Diff Detail

Event Timeline

arsenm created this revision.Aug 14 2023, 7:29 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 14 2023, 7:29 AM
arsenm requested review of this revision.Aug 14 2023, 7:29 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 14 2023, 7:29 AM
bob80905 added inline comments.Aug 14 2023, 10:58 AM
llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
268–269

Nit: is it possible to order these?
Like: {G_FCOS, G_FSIN, G_FLOG, G_FLOG2, G_FLOG10, G_FEXP, G_FEXP2, G_FEXP10, G_FPOW})

kpn added a comment.Aug 14 2023, 11:39 AM

Any plans for a strictfp/constrained version?

arsenm updated this revision to Diff 550394.Aug 15 2023, 10:50 AM
arsenm marked an inline comment as done.

Any plans for a strictfp/constrained version?

My current intention is to not add any more constrained intrinsics as an unsustainable effort in boilerplate; I think we should do call strictfp instead of duplicating every operation and ignoring target intrinsics

kpn added a comment.Aug 28 2023, 11:48 AM

This looks good. If the limited precision stuff isn't needed then I'll sign off on it.

llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
423

I assume this is clang-format's formatting?

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
6400

This is different from exp and exp2. Is the limited precision stuff not needed or doesn't make sense?

arsenm marked an inline comment as done.Aug 31 2023, 2:48 PM
arsenm added inline comments.
llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
423

Yes

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
6400

It could follow it, but it's an additional optimization that can be done separately. Plus as far as I can tell, this is only enabled with a cl::opt which I didn't know existed so the utility seems marginal

kpn accepted this revision.Sep 1 2023, 6:55 AM

LGTM

This revision is now accepted and ready to land.Sep 1 2023, 6:55 AM