This is an archive of the discontinued LLVM Phabricator instance.

NVPTX: Cleanup check for denormal mode
ClosedPublic

Authored by arsenm on Dec 6 2022, 3:56 PM.

Details

Reviewers
tra
bkramer
Summary

Go through the common query and be explicit about the supported flush
type.

Diff Detail

Event Timeline

arsenm created this revision.Dec 6 2022, 3:56 PM
arsenm requested review of this revision.Dec 6 2022, 3:56 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 6 2022, 3:56 PM
arsenm added inline comments.Dec 6 2022, 3:57 PM
llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp
374

Looks broken for double to me but I don't know what the options are

tra accepted this revision.Dec 6 2022, 3:58 PM
This revision is now accepted and ready to land.Dec 6 2022, 3:58 PM
tra added inline comments.Dec 6 2022, 4:16 PM
llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp
149–151

Huh. I wonder why are we using isHalfTy for figuring out denormal mode.

Considering that it seems to be FP32 that is the special case with an attribute of its own, it should've been IsSingleTy. Knowing whether it's fp16 or not only allows us to get correct mode for fp16, but not for the other types.

374

Indeed. I do not understand why getDenormalMode appears to single out fp32 as a special case.

arsenm added inline comments.Dec 6 2022, 4:17 PM
llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp
374

Because turn on f32 flush is the option the languages actually expose. denormal-fp-math-f32 acts as an override to denormal-fp-math

tra added inline comments.Dec 6 2022, 4:54 PM
llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp
374

OK, then the code is (and has been) broken for 'double'. I do not think we want to override denormals mode for doubles using denormal-fp-math-f32.
On the other hand, it's no more broken than it was before, so we can probably live with that until we figure out how to fix this.

https://llvm.org/docs/LangRef.html says:

" denormal-fp-math-f32" [...] Not all targets support separately setting the denormal mode per type, and no attempt is made to diagnose unsupported uses. Currently this attribute is respected by the AMDGPU and NVPTX backends.

On a side note, I wonder if the denormals handling mode may need to grow a similar override for fp16, which also has .ftz instruction variants.

arsenm added inline comments.Dec 6 2022, 5:05 PM
llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp
374

But do those imply a change in the default FP mode, or are they just operations that have flushing semantics in the default mode