This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] implement target hook isProfitableToHoist
ClosedPublic

Authored by shchenz on Mar 15 2020, 6:57 PM.

Details

Reviewers
hfinkel
nemanjai
Group Reviewers
Restricted Project
Commits
rG3f85134d710c: [PowerPC] implement target hook isProfitableToHoist
Summary

On Powerpc fma is faster than fadd + fmul for some types, (PPCTargetLowering::isFMAFasterThanFMulAndFAdd). we should implement target hook isProfitableToHoist to prevent simplifyCFGpass from breaking fma pattern by hoisting fmul to predecessor block.

Diff Detail

Event Timeline

shchenz created this revision.Mar 15 2020, 6:57 PM
lkail added a reviewer: Restricted Project.Mar 15 2020, 7:25 PM
nemanjai requested changes to this revision.Mar 16 2020, 11:46 AM
nemanjai added inline comments.
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
15390

Can we please not have the same logic in two places. Please either call this one from the other by using VT.getTypeForEVT() and MF.getFunction()
or write a separate helper function that can be called by both.

llvm/test/Transforms/SimplifyCFG/PowerPC/prefer-fma.ll
4

I think it would be preferable to pre-commit this test case with full checks produced by the script and then just show the differences here.

This revision now requires changes to proceed.Mar 16 2020, 11:46 AM
shchenz updated this revision to Diff 250685.Mar 16 2020, 8:21 PM

split out nfc patch and testcase baseline

shchenz marked 2 inline comments as done.

Thanks for your quick review @nemanjai

llvm/lib/Target/PowerPC/PPCISelLowering.cpp
15390

Split out this function as NFC patch in D76265.

nemanjai accepted this revision.Mar 18 2020, 6:51 AM

LGTM aside from a nit from me and a couple from clang-format. I'm sure you can address those on the commit.

llvm/lib/Target/PowerPC/PPCISelLowering.cpp
15399

I think we can omit the check for nullptr here since you have already checked the instruction has a use. Perhaps just change it to:
assert(User && "A single use instruction with no uses?");

Also, I think it is more common to De-Morgan-ize these conditions to something like

if (User->getOpcode() != Instruction::FSub &&
    User->getOpcode() != Instruction::FAdd)
This revision is now accepted and ready to land.Mar 18 2020, 6:51 AM
shchenz updated this revision to Diff 251261.Mar 18 2020, 8:48 PM

address comments

This revision was automatically updated to reflect the committed changes.