This is an archive of the discontinued LLVM Phabricator instance.

[X86][FMA] Optimize FNEG(FMA) Patterns
ClosedPublic

Authored by RKSimon on Nov 22 2015, 11:11 AM.

Details

Summary

X86 needs to use its own FMA opcodes, preventing the standard FNEG(FMA) pattern table recognition method used by other platforms. This patch adds support for lowering FNEG(FMA(X,Y,Z)) into a single suitably negated FMA instruction.

Fix for PR24364

Diff Detail

Repository
rL LLVM

Event Timeline

RKSimon updated this revision to Diff 40878.Nov 22 2015, 11:11 AM
RKSimon retitled this revision from to [X86][FMA] Optimize FNEG(FMA) Patterns.
RKSimon updated this object.
RKSimon added reviewers: spatel, delena, qcolombet.
RKSimon set the repository for this revision to rL LLVM.
RKSimon added a subscriber: llvm-commits.
delena added inline comments.Nov 23 2015, 2:25 AM
lib/Target/X86/X86ISelLowering.cpp
13400 ↗(On Diff #40878)

What we are doing in PerformFMACombine() ? May be we can extend there?

RKSimon added inline comments.Nov 23 2015, 6:15 AM
lib/Target/X86/X86ISelLowering.cpp
13400 ↗(On Diff #40878)

In PerformFMACombine we convert ISD::FMA nodes to the equivalent X86ISD FMADD/FMSUB/FNMADD/FNMSUB nodes based on which inputs are FNEG.

This patch deal with FNEG which has a X86ISD FMA type as its input - we don't have a PerformFNEGCombine but I could move this patch there if you think it necessary.

delena accepted this revision.Nov 23 2015, 10:38 PM
delena edited edge metadata.

I agree that the PerformFMACombine() is not the right place. May be PerformFNEGCombine() is more clear? I'll let you to decide.
LGTM.

This revision is now accepted and ready to land.Nov 23 2015, 10:38 PM
This revision was automatically updated to reflect the committed changes.