This is an archive of the discontinued LLVM Phabricator instance.

[InstSimplify] Add unary fneg to `fsub 0.0, (fneg X) ==> X` transform
ClosedPublic

Authored by cameron.mcinally on May 16 2019, 9:21 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptMay 16 2019, 9:21 AM

Fix another test I botched in r360808.

arsenm added inline comments.May 16 2019, 10:13 AM
llvm/lib/Analysis/InstructionSimplify.cpp
4372

Should keep the original comment, and add another line for the fneg case since both are handled

spatel added inline comments.May 16 2019, 10:50 AM
llvm/test/Transforms/InstSimplify/fast-math.ll
224–226

Better to commit the test fixes ahead of this patch as an NFC step, so we don't lose those diffs in case the code change has to be reverted.

cameron.mcinally marked an inline comment as done.May 16 2019, 11:39 AM
cameron.mcinally added inline comments.
llvm/lib/Analysis/InstructionSimplify.cpp
4372

That's a fair change.

There is some clunkiness here though, since an FSub(+-0.0. X) should match to an FNeg under NSZ. However, the PatternMatcher doesn't currently have a good way to match that pattern when the FMFs are inferred from a different instruction. Just FYI.

Address reviews...

cameron.mcinally marked 2 inline comments as done.May 16 2019, 12:10 PM
spatel accepted this revision.May 17 2019, 8:55 AM

LGTM

This revision is now accepted and ready to land.May 17 2019, 8:55 AM
This revision was automatically updated to reflect the committed changes.