[PATCH] D53744: [SimpleLoopUnswitch] Unswitch by experimental.guard intrinsics

Chandler Carruth via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 26 00:35:05 PDT 2018


chandlerc added a comment.

While this is a neat way to handle this, I'm a bit worried about the effects of it...

Does normal unswitch do the same thing currently?

Have you looked at how hard it would be to handle this case directly rather than by introducing a branch?



================
Comment at: lib/Transforms/Scalar/SimpleLoopUnswitch.cpp:2253-2255
+  // TODO: We don't know for sure that this guard will then be unswitched. We
+  // can make this statistics more accurate.
+  ++NumGuards;
----------------
What happens if the guard isn't unswitched? Will anything clean up the branch?


================
Comment at: lib/Transforms/Scalar/SimpleLoopUnswitch.cpp:2446-2447
+    int SuccessorsCount = isGuard(&TI) ? 2 : Visited.size();
+    assert(SuccessorsCount > 1 &&
+	   "Cannot unswitch a condition without multiple distinct successors!");
+    return Cost * (SuccessorsCount - 1);
----------------
Needs `clang-format`?


https://reviews.llvm.org/D53744





More information about the llvm-commits mailing list