[PATCH] D29399: [X86][SSE] Combine shuffle nodes with multiple uses if all the users are being combined.

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 6 05:51:58 PST 2017


RKSimon added a comment.

Thanks Andrea



================
Comment at: lib/CodeGen/SelectionDAG/SelectionDAG.cpp:7129-7141
+bool SDNode::areOnlyUsersOf(ArrayRef<const SDNode *> Nodes, const SDNode *N) {
+  bool Seen = false;
+  for (SDNode::use_iterator I = N->use_begin(), E = N->use_end(); I != E; ++I) {
+    SDNode *User = *I;
+    if (llvm::any_of(Nodes,
+                     [&User](const SDNode *Node) { return User == Node; }))
+      Seen = true;
----------------
andreadb wrote:
> Correct me if I am wrong.
> We can only return false from line 7140 if N has no users.
> 
> Assuming that the `use_empty()` is a valid scenario, you can slightly simplify the code by adding an early check to `N->use_empty()` at the beginning of the function.
We can also return false if N has any users that are not contained in Nodes.

I was going for consistency with SDNode::isOnlyUserOf - AFAICT checking for use_empty() is not going to be much quicker than calling use_begin()/use_end(), matching them and not entering the for loop.

Shout if you disagree.


Repository:
  rL LLVM

https://reviews.llvm.org/D29399





More information about the llvm-commits mailing list