This is an archive of the discontinued LLVM Phabricator instance.

[DAGCombiner, PowerPC] allow X - (fpext(-Y) --> X + fpext(Y) with multiple uses
ClosedPublic

Authored by spatel on Apr 12 2018, 3:42 PM.

Details

Summary

This is a transform that I limited in instcombine in rL329821 because it was creating more instructions in IR when the cast has multiple uses.

However, in the post-commit mailing list thread for that change, @escha wrote that an out-of-tree target had regressed from that change because fpext is free on that target. Since I don't have access to that target, I'm using PowerPC as a stand-in to show the benefit of the transform here in the backend. PowerPC is the only in-tree target that sets isFPExtFree() to 'true'.

If this looks right, then we may need to add another hook for isFPTruncFree() to fully recover from the IR change because it affected fptrunc casts too.

Diff Detail

Repository
rL LLVM

Event Timeline

spatel created this revision.Apr 12 2018, 3:42 PM
nemanjai accepted this revision.Apr 14 2018, 4:43 AM

From the PPC perspective, this is fine since the sequences are equivalent. It also seems perfectly reasonable to look through a free operation here.
However, I imagine that @escha might want to look at this as well and give the final approval.

This revision is now accepted and ready to land.Apr 14 2018, 4:43 AM

From the PPC perspective, this is fine since the sequences are equivalent. It also seems perfectly reasonable to look through a free operation here.

The sequence with fadd is better in theory because we've reduced the dependency chain (the fneg can execute in parallel now).

However, I imagine that @escha might want to look at this as well and give the final approval.

There are follow-up comments in the post-commit thread for rL329821. The source of the problem for the original motivating case is unknown. But I think this change can't hurt that target, so I'll proceed with this one.

This revision was automatically updated to reflect the committed changes.