This is an archive of the discontinued LLVM Phabricator instance.

[NVPTX] Fix NVPTX lowering of frem when denominator is infinite.
ClosedPublic

Authored by bchetioui on Jan 2 2023, 8:09 AM.

Details

Summary

frem x, {+,-}inf must return x to match the specification of LLVM's frem.

Diff Detail

Event Timeline

bchetioui created this revision.Jan 2 2023, 8:09 AM
bchetioui requested review of this revision.Jan 2 2023, 8:09 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 2 2023, 8:09 AM
bchetioui updated this revision to Diff 485866.Jan 2 2023, 8:21 AM

Fix vertical alignment.

herhut added a subscriber: bkramer.Jan 3 2023, 8:46 AM

This looks reasonable to me but @tra or @bkramer would be better reviewers.

llvm/lib/Target/NVPTX/NVPTXInstrInfo.td
681

Maybe give these more canonical names? Something like 'TESTINF_f32r`. The f is redundant (there is no inf for int) but is more in line with how things are named where the suffix after _ is the type.

tra added inline comments.Jan 3 2023, 11:38 AM
llvm/lib/Target/NVPTX/NVPTXInstrInfo.td
605

Nit: It's more of a TODO, IMO. :-)

I wonder if the instruction actually provides any benefit over cmp+selp on the SASS level. I suspect that it probably does not, and implementing it would just give us a bit nicer PTX w/o much of an effect on the actual GPU code.

1312–1313

This would add selp+testinf unconditionally to all frem lowerings. While it is correct, I wonder if we may want to avoid that when we're in fast-math mode when we only care about finite math.

bchetioui updated this revision to Diff 486189.Jan 4 2023, 12:57 AM

Address comments requested by reviewers.

bchetioui marked 2 inline comments as done.Jan 4 2023, 1:00 AM

Thanks for the review, @tra and @herhut!

llvm/lib/Target/NVPTX/NVPTXInstrInfo.td
605

Done. (Though this is not really part of the change, I moved this block from below to satisfy requirements re. definition order. :-))

tra accepted this revision.Jan 4 2023, 10:58 AM
This revision is now accepted and ready to land.Jan 4 2023, 10:58 AM
This revision was automatically updated to reflect the committed changes.