This is an archive of the discontinued LLVM Phabricator instance.

ValueTracking: Implement computeKnownFPClass for fdiv for nan/inf handling
ClosedPublic

Authored by arsenm on Apr 12 2023, 1:59 PM.

Diff Detail

Event Timeline

arsenm created this revision.Apr 12 2023, 1:59 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 12 2023, 1:59 PM
arsenm requested review of this revision.Apr 12 2023, 1:59 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
foad added inline comments.Apr 13 2023, 1:07 AM
llvm/lib/Analysis/ValueTracking.cpp
4506

If InterestedClasses doesn't contain Inf or Nan, can't you bail out even earlier, before computing KnownRHS?

4515

No, tiny/huge (both finite non-zero values) can produce zero.

4526

No, huge/tiny (both finite non-zero values) can produce inf.

arsenm updated this revision to Diff 513177.Apr 13 2023, 5:09 AM
arsenm marked 3 inline comments as done.
foad added inline comments.Apr 13 2023, 5:31 AM
llvm/lib/Analysis/ValueTracking.cpp
4494

After the other fixes we are no longer interested in fcInf here.

4509

WantInfNan is always true here

arsenm updated this revision to Diff 514927.Apr 19 2023, 6:00 AM
arsenm marked 2 inline comments as done.
jcranmer-intel accepted this revision.Apr 19 2023, 1:24 PM
This revision is now accepted and ready to land.Apr 19 2023, 1:24 PM
foad added inline comments.Apr 20 2023, 2:57 AM
llvm/lib/Analysis/ValueTracking.cpp
4514

Could it be an FDiv ConstantExpr?

nikic added inline comments.Apr 20 2023, 3:07 AM
llvm/lib/Analysis/ValueTracking.cpp
4514

fdiv is not supported in constant expressions anymore.

foad added inline comments.Apr 20 2023, 3:09 AM
llvm/lib/Analysis/ValueTracking.cpp
4514

Great! I had a quick look but didn't find the commit that removed them, or where to look for an up to date list of supported operators.

nikic added inline comments.Apr 20 2023, 3:12 AM
llvm/lib/Analysis/ValueTracking.cpp
4514

For binops in particular it's ConstantExpr::isSupportedBinOp(). It looks like I need to update the listing at https://llvm.org/docs/LangRef.html#constant-expressions with the current state.