This is an archive of the discontinued LLVM Phabricator instance.

[GlobalISel] Implement fewerElements legalization for vector reductions.
ClosedPublic

Authored by aemerson on Feb 21 2021, 2:22 PM.

Details

Summary

This patch adds 2 methods, one for power-of-2 vectors which use tree reductions using vector ops, before a final reduction op. For non-pow-2 types it generates multiple narrow reductions and combines the values with scalar ops.

The vabs test is modified because fixing some fallback results in an unintended match.

Diff Detail

Event Timeline

aemerson created this revision.Feb 21 2021, 2:22 PM
aemerson requested review of this revision.Feb 21 2021, 2:22 PM
aemerson edited the summary of this revision. (Show Details)Feb 21 2021, 2:45 PM
arsenm added inline comments.Feb 23 2021, 11:28 AM
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
4240

I've been trying to move away from using extractParts. Can you reframe this with extractGCDType to handle the odd cases?

aemerson added inline comments.Mar 1 2021, 4:07 PM
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
4240

I'm having trouble constructing test cases that don't fall over due some missing pieces of legalization. E.g. no support for non-pow-2 num-elements, and using G_IMPLICIT_DEF also falls over because it generates concats that we also don't support (a whole can of worms I'm not sure how to begin fixing). Can we stick with this method before having to do all that?

arsenm added inline comments.Mar 2 2021, 5:21 AM
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
4289

Missing newline

4306

Could avoid this copy by using DstReg on the last iteration

aemerson updated this revision to Diff 327571.Mar 2 2021, 1:48 PM

Address comments.

arsenm accepted this revision.Mar 29 2021, 3:29 PM
This revision is now accepted and ready to land.Mar 29 2021, 3:29 PM
This revision was landed with ongoing or failed builds.Mar 30 2021, 11:28 AM
This revision was automatically updated to reflect the committed changes.