This is an archive of the discontinued LLVM Phabricator instance.

[ValueTracking] Fix CannotBeOrderedLessThanZero() for fdiv (PR58046)
ClosedPublic

Authored by nikic on Sep 29 2022, 6:53 AM.

Details

Summary

When checking the RHS of fdiv, we should set the SignBitOnly flag, because a negative zero can become -Inf, which is ordered less than zero.

Fixes https://github.com/llvm/llvm-project/issues/58046.

Diff Detail

Event Timeline

nikic created this revision.Sep 29 2022, 6:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 29 2022, 6:53 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
nikic requested review of this revision.Sep 29 2022, 6:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 29 2022, 6:53 AM
arsenm accepted this revision.Sep 29 2022, 8:00 AM
arsenm added a subscriber: arsenm.

LGTM

This revision is now accepted and ready to land.Sep 29 2022, 8:00 AM
spatel accepted this revision.Sep 29 2022, 8:00 AM

LGTM

llvm/test/Transforms/InstSimplify/floating-point-compare.ll
1002

This wasn't just wrong...it was really, really wrong. :)
https://alive2.llvm.org/ce/z/p4D5Bo

Worth a TODO; some missing analysis of int-to-FP casts?

nikic added inline comments.Sep 29 2022, 8:06 AM
llvm/test/Transforms/InstSimplify/floating-point-compare.ll
1002

It looks like our fmul zero folds currently only support FMF folds, not anything ValueTracking based: https://github.com/llvm/llvm-project/blob/8b38a2c0a55a9140115a91959326918d99bea435/llvm/lib/Analysis/InstructionSimplify.cpp#L5313-L5319

This revision was landed with ongoing or failed builds.Sep 29 2022, 8:08 AM
This revision was automatically updated to reflect the committed changes.