[PATCH] D47735: [SelectionDAG] Create rotates more aggressively

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 6 15:26:51 PDT 2018


efriedma added inline comments.


================
Comment at: lib/CodeGen/SelectionDAG/DAGCombiner.cpp:4893
+  SmallVector<SDValue,8> OredOps;
+  for (unsigned i = 0; i != WorkQ.size(); ++i) {
+    SDValue V = WorkQ[i];
----------------
Please use `while (!WorkQ.empty())` instead of this for loop.


================
Comment at: lib/CodeGen/SelectionDAG/DAGCombiner.cpp:4928-4929
+  // If there is at least one left and right shift, do pairwise matching.
+  if (LeftCount == 0 || LeftCount == TotalCount)
+    return nullptr;
+
----------------
This check is redundant.


================
Comment at: lib/CodeGen/SelectionDAG/DAGCombiner.cpp:4933
+  for (unsigned L = 0; L != LeftCount; ++L) {
+    for (unsigned R = LeftCount; R != TotalCount; ++R) {
+      if (!OredOps[R])
----------------
Could you sort the nodes so that shifts with the same LHS end up together, and use that to change this loop into something that isn't O(N^2)?


================
Comment at: lib/CodeGen/SelectionDAG/DAGCombiner.cpp:4942
+        CreatedRotate = true;
+        break;
+      }
----------------
Use of "break" here is weird; it breaks out of the inner loop, but not the outer loop.

I'd like to see a testcase with multiple rotates or'ed together.


Repository:
  rL LLVM

https://reviews.llvm.org/D47735





More information about the llvm-commits mailing list