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

Chandler Carruth via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 26 02:25:25 PDT 2018


chandlerc accepted this revision.
chandlerc added a comment.
This revision is now accepted and ready to land.

Generally looks fine, two minor adjustments below and LGTM once the underlying cleanuppad change lands.



================
Comment at: lib/Transforms/Scalar/SimpleLoopUnswitch.cpp:2241-2242
+
+  // TODO: We don't know for sure that this guard will then be unswitched. We
+  // can make this statistics more accurate.
+  ++NumGuards;
----------------
Update comment to reflect that this is now accurate?


================
Comment at: lib/Transforms/Scalar/SimpleLoopUnswitch.cpp:2258-2265
+  // Whether or not we should also collect guards in the loop.
+  bool CollectGuards = false;
+  if (UnswitchGuards) {
+    auto *GuardDecl = L.getHeader()->getParent()->getParent()->getFunction(
+        Intrinsic::getName(Intrinsic::experimental_guard));
+    if (GuardDecl && !GuardDecl->use_empty())
+      CollectGuards = true;
----------------
I assume this is trying to avoid the cost of looking for a guard intrinsic? We already walk all the instructions in the loop several times in this routine, so I'm not sure this matters much in practice. I'd just skip this and check the flag below.


https://reviews.llvm.org/D53744





More information about the llvm-commits mailing list