This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] sink FP negation of operands through select
ClosedPublic

Authored by spatel on May 6 2019, 11:15 AM.

Details

Summary

I was looking at an independent problem for FP min/max patterns, when I noticed we don't always get this:

Cond ? -X : -Y --> -(Cond ? X : Y)

...even with the legacy IR form of fneg in the case with extra uses.

This fold isn't included in D61447. We might want to split that up into pieces that are similar to this patch, so we can gradually introduce the new 'fneg' into IR without causing regressions.

Diff Detail

Repository
rL LLVM

Event Timeline

spatel created this revision.May 6 2019, 11:15 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 6 2019, 11:15 AM
cameron.mcinally accepted this revision.May 6 2019, 11:25 AM

LGTM.

llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
347 ↗(On Diff #198312)

Do you know what pass needs updating so that we can use the UnOp form? I could work on that next...

If you don't know, that's fine. I can dig it up.

This revision is now accepted and ready to land.May 6 2019, 11:25 AM
spatel marked an inline comment as done.May 6 2019, 12:06 PM
spatel added inline comments.
llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
347 ↗(On Diff #198312)

I think it's mostly within instcombine - anywhere we're implicitly or explicitly (m_BinOp) matching generic binop patterns will not match with the new fneg in IR.

llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
347 ↗(On Diff #198312)

Ok. @kpn already has the bulk of InstCombine covered, so I'll leave that to him. If that's okay with you, Kevin.

This revision was automatically updated to reflect the committed changes.