[PATCH] Handle resolvable branches in complete loop unroll heuristic.

Chandler Carruth chandlerc at gmail.com
Thu Jun 4 17:19:02 PDT 2015


Totally the right direction, just some quick comments here. This patch will likely change some based on my comments in http://reviews.llvm.org/D10205 but these are independent issues.


================
Comment at: lib/Transforms/Scalar/LoopUnrollPass.cpp:558-559
@@ +557,4 @@
+          Value *Cond = BI->getCondition();
+          if (ConstantInt *SimpleCond
+              = dyn_cast_or_null<ConstantInt>(SimplifiedValues.lookup(Cond))) {
+            BBWorklist.insert(BI->getSuccessor(SimpleCond->isZero() ? 1 : 0));
----------------
I don't think the 'Cond' variable is buying you much.

I would also write the condition differently as the only null case is where we have no simplified value. The type must always be an int. So:

  if (Constant *SimpleCond = SimplifiedValues.lookup(BI->getCondition())) {
    BBWorklist.insert(BI->getSuccessor(cast<ConstantInt>(SimpleCond)->isZero() ? 1 : 0));



================
Comment at: lib/Transforms/Scalar/LoopUnrollPass.cpp:565-568
@@ +564,6 @@
+      } else if (SwitchInst *SI = dyn_cast<SwitchInst>(TI)) {
+        Value *Cond = SI->getCondition();
+        if (ConstantInt *SimpleCond
+            = dyn_cast_or_null<ConstantInt>(SimplifiedValues.lookup(Cond))) {
+          BBWorklist.insert(SI->findCaseValue(SimpleCond).getCaseSuccessor());
+          continue;
----------------
Same comment as above.

http://reviews.llvm.org/D10206

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list