This is an archive of the discontinued LLVM Phabricator instance.

[SDAG] Add SDNodes for umin, umax, smin and smax
ClosedPublic

Authored by jmolloy on May 13 2015, 7:30 AM.

Details

Summary

This adds new SDNodes for signed/unsigned min/max. These nodes are built from
select/icmp pairs matched at SDAGBuilder stage.

This patch adds the nodes, as well as legalization support and sets them to
be "expand" for all targets.

NFC for now; this will be tested when I switch AArch64 to using these new
nodes.

Diff Detail

Repository
rL LLVM

Event Timeline

jmolloy updated this revision to Diff 25682.May 13 2015, 7:30 AM
jmolloy retitled this revision from to [SDAG] Add SDNodes for umin, umax, smin and smax.
jmolloy updated this object.
jmolloy edited the test plan for this revision. (Show Details)
jmolloy added reviewers: resistor, t.p.northover, delena.
jmolloy set the repository for this revision to rL LLVM.
jmolloy added a subscriber: Unknown Object (MLST).
delena added inline comments.May 13 2015, 11:13 PM
lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
3310
lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
562

You can use PromoteIntRes_SimpleIntBinOp(), it does the same.

jmolloy updated this revision to Diff 25761.May 14 2015, 2:53 AM

Hi Elena,

Updated diff adjusting for your review comments.

Cheers,

James

delena added inline comments.May 14 2015, 3:58 AM
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
2258

Why NumValues should be 1? You can do the same for each value and then merge them together.

2275

you can put the "while" (5 lines above) under this "if"

delena edited edge metadata.May 14 2015, 5:31 AM

ComputeValueVTs() is for arrays and structures, not for splitting one value into two.
For arrays, you'll have UMIN for each pair A[i] B[i], instead of "select".
For a structure, you may have a mix of UMIN and "select" since the types may be different.

jmolloy updated this revision to Diff 25770.May 14 2015, 6:52 AM
jmolloy edited edge metadata.

Hi Elena,

Updated according to comments. I changed the check - we still need to check that all the VTs are the same, otherwise the transformation would be completely incorrect.

The while statement can't be moved inside the if, because the while statement modifies "VT". The aim is to peel off SplitVector operations and suchlike until we get to the bottommost type, which we then check if it's legal or custom.

Cheers,

James

Hi James,

I thought more about number of values on my way home and concluded that you was right.
You'll never see more than one value on MIN/MAX pattern,
because it comes from "icmp" instruction, that does not work with aggregate types.

  • Elena

Hi Elena,

Well, the code as it now stands is at least future proofed :) it hasn't added any complexity to support multiple values, so I suggest it just stays like that.

Cheers,

James

I agree, I think you can commit it. I'll add target lowering for X86.

  • Elena
jmolloy accepted this revision.May 15 2015, 2:25 AM
jmolloy added a reviewer: jmolloy.

Committed r237423.

This revision is now accepted and ready to land.May 15 2015, 2:25 AM
jmolloy closed this revision.May 15 2015, 2:25 AM