This is an archive of the discontinued LLVM Phabricator instance.

[LV] Refactor getExtendedAddReductionCost to support other extended reduction more than Add.
ClosedPublic

Authored by jacquesguan on Jul 31 2022, 11:24 PM.

Details

Summary

Now the API getExtendedAddReductionCost is used to determine extended Add reduction with optional Mul. For Arm, it could cover the cases. But for other target, for example: RISCV, they support other kinds of extended recution, such as FAdd.

This patch does the following changes:
1, Split getExtendedAddReductionCost into 2 new API: getExtendedReductionCost which handles the extended reduction with addtional input of Opcode; getMulAccReductionCost which handle the MLA cases the getExtendedAddReductionCost.
2, Refactor getReductionPatternCost, add some contraint condition to make sure the getMulAccReductionCost should only handle the reuction of Add + Mul.

Diff Detail

Event Timeline

jacquesguan created this revision.Jul 31 2022, 11:24 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 31 2022, 11:24 PM
jacquesguan requested review of this revision.Jul 31 2022, 11:24 PM

I see - this sounds OK to me. I'm a little surprised that RISCV would want to use inloop reductions, but if they perform an extend then that might make sense. It sounds like we could generalize a few things, we have only needed extended add and mla in the past.

llvm/include/llvm/CodeGen/BasicTTIImpl.h
2350

Fold the ExtCost *= 2 into the return statement below?

llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
1708

You can remove this - there are no other ops under MVE

reames added a subscriber: david-arm.EditedAug 1 2022, 7:51 AM

The API changes here LGTM, but please wait for @dmgreen to approve the ARM target changes.

Edit: I'd tagged the wrong David.

Address comment.

jacquesguan marked 2 inline comments as done.Aug 1 2022, 11:33 PM
jacquesguan added inline comments.
llvm/include/llvm/CodeGen/BasicTTIImpl.h
2350

Done.

llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
1708

Done.

dmgreen accepted this revision.Aug 2 2022, 12:34 AM

Thanks. LGTM

This revision is now accepted and ready to land.Aug 2 2022, 12:34 AM
This revision was landed with ongoing or failed builds.Aug 2 2022, 1:03 AM
This revision was automatically updated to reflect the committed changes.