This is an archive of the discontinued LLVM Phabricator instance.

ValueTracking: Drop rounding mode check for constrained_sqrt in CannotBeNegativeZero
ClosedPublic

Authored by arsenm on May 16 2023, 2:31 PM.

Details

Summary

The only value that can produce -0 is exactly -0, no rounding is involved. If the
denormal mode has flushed denormal inputs, a negative value could produce -0.
The constrained intrinsics do not track the denormal mode, and this is just
generally broken in the current set of FP predicates. The move to computeKnownFPClass
will address some of these issues.

Diff Detail

Event Timeline

arsenm created this revision.May 16 2023, 2:31 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 16 2023, 2:31 PM
arsenm requested review of this revision.May 16 2023, 2:31 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 16 2023, 2:31 PM
Herald added a subscriber: wdng. · View Herald Transcript
sepavloff accepted this revision.May 17 2023, 7:18 AM

LGTM.

llvm/lib/Analysis/ValueTracking.cpp
3809

Is this FIXME useful? How could denormal handling change this behavior?

This revision is now accepted and ready to land.May 17 2023, 7:18 AM
arsenm marked an inline comment as done.May 17 2023, 7:29 AM
arsenm added inline comments.
llvm/lib/Analysis/ValueTracking.cpp
3809

If you have preserve-sign inputs, another negative denormal could be implicitly treated as -0 and return -0. This is fixed in the new computeKnownFPClass implementation

sepavloff added inline comments.May 17 2023, 8:33 AM
llvm/lib/Analysis/ValueTracking.cpp
3809

In this case CannotBeNegativeZero(Call->getArgOperand(0)...) returns false and logic of this code remains valid, no?

arsenm marked an inline comment as done.May 18 2023, 10:12 AM
arsenm added inline comments.
llvm/lib/Analysis/ValueTracking.cpp
3809

No, because the current CannotBeNegativeZero doesn't consider the denormal mode at all.

foad accepted this revision.May 19 2023, 1:00 AM

LGTM