Page MenuHomePhabricator

[TLI][PowerPC] Introduce TLI query to check if MULH is cheaper than MUL + SHIFT
ClosedPublic

Authored by amyk on Apr 15 2020, 9:47 PM.

Details

Summary

This patch introduces a TargetLowering query, isMulhCheaperThanMulShift.

Currently in DAG Combine, it will transform mulhs/mulhu into a
wider multiply and a shift if the wide multiply is legal.

This TLI function is implemented on 64-bit PowerPC, as it is more desirable to
have multiply-high over multiply + shift for words and doublewords. Having
multiply-high can also aid in further transformations that can be done.

Diff Detail

Event Timeline

amyk created this revision.Apr 15 2020, 9:47 PM
amyk edited the summary of this revision. (Show Details)Apr 15 2020, 9:48 PM
nemanjai accepted this revision.Apr 24 2020, 5:45 AM
nemanjai added reviewers: efriedma, spatel.

LGTM. However, give this patch a couple of days in case others in the community would like to chime in.

This revision is now accepted and ready to land.Apr 24 2020, 5:46 AM
RKSimon added inline comments.
llvm/include/llvm/CodeGen/TargetLowering.h
1657

If we add X86/SSE support we might need a IsSigned flag but unless PPC have a use case right now I don't think this needs to be added yet.

amyk marked an inline comment as done.May 5 2020, 6:19 PM
amyk added inline comments.
llvm/include/llvm/CodeGen/TargetLowering.h
1657

Thanks for having a look. The current use case is that the transformation in https://reviews.llvm.org/D78272 actually relies on this patch.

This revision was automatically updated to reflect the committed changes.