This is an archive of the discontinued LLVM Phabricator instance.

[FPEnv] WIP on threading fneg through llvm
AbandonedPublic

Authored by kpn on May 2 2019, 9:20 AM.

Details

Summary

This is my work-in-progress code for threading fneg from the IRBuilder on through the optimization passes. It isn't in shape to commit, but perhaps should be seen for discussion on direction at least.

At least some of the optimization passes use the IRBuilder, so adding FNeg there means the optimization passes must be changed in concert. Otherwise code quality is affected.

Currently some of the tests are still failing because the Reassociate pass doesn't know how to deal with a unary instruction. I don't know what comes after that is fixed.

Diff Detail

Repository
rL LLVM

Event Timeline

kpn created this revision.May 2 2019, 9:20 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 2 2019, 9:20 AM

Thanks for working on this, Kevin. It looks like the general direction is good. A couple small comments inline. I also noticed some of the tests still need updating to replace fsub's, but I assume you know that.

@spatel I'm not a PatternMatch expert, but I think that change is what we wanted. That is, to continue to match FSub(-0.0, X) as an FNeg(X).

I'm currently working on ConstantExpr folding for FNeg in D61419. And soon to be looking at FNeg folding in InstructionSimplify. Just FYI...

lib/Transforms/InstCombine/InstCombineAddSub.cpp
1938

We should also do:

-undef -> undef

lib/Transforms/Scalar/Reassociate.cpp
887

Comment needs to be updated.

@spatel I'm not a PatternMatch expert, but I think that change is what we wanted. That is, to continue to match FSub(-0.0, X) as an FNeg(X).

Just FYI that an equivalent patch was made to the PatternMatcher in D61520. I needed this for some FNeg constant folding work. Thanks for the inspirations, Kevin.

kpn added a comment.May 3 2019, 9:54 AM

@spatel I'm not a PatternMatch expert, but I think that change is what we wanted. That is, to continue to match FSub(-0.0, X) as an FNeg(X).

Just FYI that an equivalent patch was made to the PatternMatcher in D61520. I needed this for some FNeg constant folding work. Thanks for the inspirations, Kevin.

Glad to help!

kpn abandoned this revision.Jun 5 2019, 6:16 AM

I don't think this needs to be open anymore.