[PATCH] D90247: [AArch64] Add legalizations for VECREDUCE_SEQ_FADD

Cameron McInally via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 27 09:39:10 PDT 2020


cameron.mcinally created this revision.
cameron.mcinally added reviewers: paulwalker-arm, kmclaughlin, nikic, efriedma, sdesmalen.
Herald added subscribers: llvm-commits, danielkiss, hiraditya, kristof.beyls.
Herald added a reviewer: rengolin.
Herald added a project: LLVM.
cameron.mcinally requested review of this revision.

Continuing from D89162 <https://reviews.llvm.org/D89162>...

I think I stumbled across the motivation for the ExpandReductions pass. If we wait until Legalization to expand the ordered reductions, we end up with suboptimal code for illegal types. And it's pretty bad. We could end up with O(n/2) extra operations.

A good example of this can be seen in `@test_v3f32` from `vecreduce-fadd-legalization-strict.ll`. Here we end up with 4 FADDs, instead of the 3 FADDs required. The newly added FADD is the result of widening the illegal v3f32 vector type to v4f32, where the newly added element in the reduction is the "neutral" value, 0.0.

Question is... should we be optimizing for exceptional cases? Eh, probably not IMHO. But I could see users filing bug reports for the extra operations. What does everyone else think?

[***Also note that I decided to turn these new legalizations on for NEON, and not just SVE. NEON had a number of existing tests, so it made sense to reuse them. And I'm still missing legalization support for some other actions, like SoftenFloat and PromoteFloat. I did not find existing tests for those actions.***]


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90247

Files:
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
  llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h
  llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
  llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
  llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.h
  llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
  llvm/test/CodeGen/AArch64/sve-fixed-length-fp-reduce.ll
  llvm/test/CodeGen/AArch64/vecreduce-fadd-legalization-strict.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90247.301027.patch
Type: text/x-patch
Size: 18240 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201027/adc5f4fc/attachment.bin>


More information about the llvm-commits mailing list