This is an archive of the discontinued LLVM Phabricator instance.

ValueTracking: ldexp cannot return denormals based on range of exponent
ClosedPublic

Authored by arsenm on Jul 7 2023, 11:37 AM.

Details

Summary

The implementations of a number of math functions on amdgpu involve
pre and post-scaling the inputs out of the denormal range. If these
are chained together we can possibly fold them out.

computeConstantRange seems weaker than computeKnownBits, so this
regresses some of the older vector tests.

Diff Detail

Event Timeline

arsenm created this revision.Jul 7 2023, 11:37 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 7 2023, 11:37 AM
arsenm requested review of this revision.Jul 7 2023, 11:37 AM
Herald added a reviewer: sstefan1. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
Herald added a subscriber: wdng. · View Herald Transcript
foad added inline comments.Jul 11 2023, 2:12 AM
llvm/lib/Analysis/ValueTracking.cpp
4710–4712

I don't think "sign bit" is relevant here. I guess you're subtracting 1 because you're not interested in the "implicit bit" at the front of the mantissa.

4711

Ranges can wrap, so getLower() is not necessarily the smallest value in the range.

4716

Why do you have to handle this case here? Surely something else should already have simplified the operand to an actual constant?

4720–4721

Could relax this to "power is <= 0", but there is no handy helper for that.

arsenm added inline comments.Jul 11 2023, 3:57 AM
llvm/lib/Analysis/ValueTracking.cpp
4716

D149587 folds these out. However, these ValueTracking functions tend to try to handle all the edge cases. Some of those trivial folds are implemented with these functions (e.g. D151887 tries to consolidate the fcmp simplifications to use computeKnownFPClass)

arsenm updated this revision to Diff 539102.Jul 11 2023, 7:49 AM
arsenm marked 2 inline comments as done.
foad accepted this revision.Jul 11 2023, 8:13 AM
This revision is now accepted and ready to land.Jul 11 2023, 8:13 AM