[PATCH] D72224: [LegalizeVectorOps] Improve handling of multi-result operations.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 5 00:26:48 PST 2020


craig.topper created this revision.
craig.topper added reviewers: RKSimon, spatel, efriedma, kpn, uweigand.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.

This system wasn't very well designed for multi-result nodes. As
a consequence they weren't consistently registered in the
LegalizedNodes map leading to nodes being revisited for different
results.

I've removed the "Result" variable from the main LegalizeOp method
and used a SDNode* instead. The result number from the incoming
Op SDValue is only used for deciding which result to return to the
caller. When LegalizeOp is called it should always register a
legalized result for all of its results. Future calls for any other
result should be pulled for the LegalizedNodes map.

Legal nodes will now register all of their results in the map
instead of just the one we were called for.

The Expand and Promote handling to use a vector of results similar
to LegalizeDAG. Each of the new results is then re-legalized and
logged in the LegalizedNodes map for all of the Results for the
node being legalized. None of the handles register their own
results now. And none call ReplaceAllUsesOfValueWith now.

Custom handling now always passes result number 0 to LowerOperation.
This matches what LegalizeDAG does. Since the introduction of
STRICT nodes, I've encountered several issues with X86's custom
handling being called with an SDValue pointing at the chain and
our custom handlers using that to get a VT instead of result 0.
This should prevent us from having any more of those issues. On
return we will update the LegalizedNodes map for all results so
we shouldn't call the custom handler again for each result number.

I want to push SDNode* further into the Expand and Promote
handlers, but I've left that for a follow to keep this patch size
down. I've created a dummy SDValue(Node, 0) to keep the handlers
working.

This replaces D71861 <https://reviews.llvm.org/D71861>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72224

Files:
  llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72224.236229.patch
Type: text/x-patch
Size: 30927 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200105/82a1fc50/attachment.bin>


More information about the llvm-commits mailing list