This is an archive of the discontinued LLVM Phabricator instance.

[FPEnv][InstSimplify] Fold fsub X, +0 ==> X
ClosedPublic

Authored by kpn on Feb 3 2022, 11:13 AM.

Details

Summary

Currently the fsub optimizations in InstSimplify don't know how to fold X - +0.0 to X when using the constrained intrinsics. This adds the support.

This review is split out from D107285.

Diff Detail

Event Timeline

kpn created this revision.Feb 3 2022, 11:13 AM
kpn requested review of this revision.Feb 3 2022, 11:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 3 2022, 11:13 AM
sepavloff added inline comments.Feb 7 2022, 3:06 AM
llvm/lib/Analysis/InstructionSimplify.cpp
5139

What if X==+0 and rounding is downward? In this case fsub X, +0 should produce -0.0 (https://en.wikipedia.org/wiki/Signed_zero#Arithmetic).

nlopes added a comment.Feb 7 2022, 3:19 AM

FWIW, I added support for constrained fadd/fsub/fmul/fdiv to Alive2 yesterday.

FWIW, I added support for constrained fadd/fsub/fmul/fdiv to Alive2 yesterday.

Sounds great!

I tried to play with this case, but got failure: https://alive2.llvm.org/ce/z/BV68q5 .

nlopes added a subscriber: regehr.Feb 7 2022, 8:32 AM

FWIW, I added support for constrained fadd/fsub/fmul/fdiv to Alive2 yesterday.

Sounds great!

I tried to play with this case, but got failure: https://alive2.llvm.org/ce/z/BV68q5 .

let's ping @regehr to see if he has time to update the online version.

kpn updated this revision to Diff 407595.Feb 10 2022, 10:15 AM

Update for review comments: don't fold away a case that can and should result in -0.0. Add tests for this very case.

This revision is now accepted and ready to land.Feb 14 2022, 8:08 AM
This revision was landed with ongoing or failed builds.Feb 14 2022, 8:57 AM
This revision was automatically updated to reflect the committed changes.