This is an archive of the discontinued LLVM Phabricator instance.

[GlobalISel] Add G_VECREDUCE_* opcodes for vector reductions
ClosedPublic

Authored by aemerson on Oct 2 2020, 12:01 PM.

Details

Summary

These mirror the IR and SelectionDAG intrinsics & nodes.

Opcodes added:
G_VECREDUCE_SEQ_FADD
G_VECREDUCE_SEQ_FMUL
G_VECREDUCE_FADD
G_VECREDUCE_FMUL
G_VECREDUCE_FMAX
G_VECREDUCE_FMIN
G_VECREDUCE_ADD
G_VECREDUCE_MUL
G_VECREDUCE_AND
G_VECREDUCE_OR
G_VECREDUCE_XOR
G_VECREDUCE_SMAX
G_VECREDUCE_SMIN
G_VECREDUCE_UMAX
G_VECREDUCE_UMIN

Diff Detail

Event Timeline

aemerson created this revision.Oct 2 2020, 12:01 PM
aemerson requested review of this revision.Oct 2 2020, 12:01 PM
arsenm added inline comments.Oct 2 2020, 2:21 PM
llvm/docs/GlobalISel/GenericOpcode.rst
553

This name is extremely confusing since these aren't strict FP operations

aemerson added inline comments.Oct 2 2020, 4:14 PM
llvm/docs/GlobalISel/GenericOpcode.rst
553

What other name do you suggest? If we change it then we should also change the SDAG node too.

VECREDUCE_STRICT_ORDER_FADD? VECREDUCE_ORDERED_FADD? VECREDUCE_SEQ_FADD?

nikic added a subscriber: nikic.Oct 3 2020, 12:59 AM
nikic added inline comments.
llvm/docs/GlobalISel/GenericOpcode.rst
553

I've also found the naming of these SDAG nodes rather confusing. A rename to something like VECREDUCE_ORDERED_FADD would be great.

aemerson added inline comments.Oct 3 2020, 12:31 PM
llvm/docs/GlobalISel/GenericOpcode.rst
553

I'm leaning towards VECREDUCE_SEQ_FADD myself since the term "ordered" is already used in FP contexts.

Patch to rename the SDNode name in D88791.

aemerson updated this revision to Diff 296802.Oct 7 2020, 2:55 PM

Rename the STRICT variants to SEQ, consistent with the rename of the SDAG nodes.

aemerson updated this revision to Diff 296872.Oct 7 2020, 11:26 PM
aemerson edited the summary of this revision. (Show Details)

Non-sequential fadd/fmul reductions also take a scalar input.

arsenm accepted this revision.Oct 8 2020, 7:02 AM
arsenm added inline comments.
llvm/test/MachineVerifier/test_vector_reductions.mir
2

Missing space before RUN

19–21

Don't need this

This revision is now accepted and ready to land.Oct 8 2020, 7:02 AM
This revision was landed with ongoing or failed builds.Oct 8 2020, 10:33 AM
This revision was automatically updated to reflect the committed changes.

@arsenm Note: the ops defined in this patch differ a bit from the SelectionDAG ones. For GlobalISel I kept the scalar accumulator that the fadd/fmul have for the opcode too. SDAG breaks these apart into the reduction and a separate fadd/fmul op. Not clear to me yet if there's a significant advantage either way.