This is an archive of the discontinued LLVM Phabricator instance.

ValueTracking: Implement computeKnownFPClass for fpext
ClosedPublic

Authored by arsenm on Apr 9 2023, 7:37 PM.

Details

Summary

Not sure the denormal handling logic applies for some of the exotic FP types

Diff Detail

Event Timeline

arsenm created this revision.Apr 9 2023, 7:37 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 9 2023, 7:37 PM
arsenm requested review of this revision.Apr 9 2023, 7:37 PM
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

Nine of the really exotic formats I know (the FP8 series) have type-level representations in LLVM unless I missed something ... and for them it's fptrunc I'd be worried about, not fpext

But also, I don't think the "abnormals extend to normals" property is true for bfloat -> float, since a bfloat is an IEEE float with the bottom 16 bits of the mantissa cut off.

arsenm updated this revision to Diff 512774.Apr 12 2023, 4:37 AM

Check exponent range for subnormal handling

arsenm updated this revision to Diff 513253.Apr 13 2023, 8:37 AM

Fix vectors

llvm/lib/Analysis/ValueTracking.cpp
4627–4631

If the mantissa is sufficiently long, then a subnormal could still be a subnormal in a number with longer range. While this holds true for all the >=16-bit fp types, I'm not sure this holds true for the different FP8 types.

arsenm marked an inline comment as done.Apr 14 2023, 3:10 PM
arsenm added inline comments.
llvm/lib/Analysis/ValueTracking.cpp
4627–4631

I missed fltSemantics::isRepresentableBy (don't understand why fltSemantics is treated so opaquely)

arsenm marked an inline comment as done.Apr 14 2023, 4:45 PM
arsenm added inline comments.
llvm/lib/Analysis/ValueTracking.cpp
4627–4631

Which also seems to not behave as expected for the bf16->f32 case

arsenm added inline comments.Apr 14 2023, 4:47 PM
llvm/lib/Analysis/ValueTracking.cpp
4627–4631

Which would be because it doesn't have the same purpose

arsenm updated this revision to Diff 513890.Apr 15 2023, 4:59 AM

Move condition into APFloat. Take a stab at guarding against exotic formats with large mantissas, although I don't think this is a practical problem (if the precision isn't larger, should fpext even be a valid operation to perform)?

ping, this is the most annoying of the set since the APFloat touch triggers large rebuilds

krzysz00 accepted this revision.Apr 20 2023, 8:40 AM

Seems reasonable to me.

This revision is now accepted and ready to land.Apr 20 2023, 8:40 AM