[PATCH] [SimplifyCFG] threshold for folding branches with common destination

hfinkel at anl.gov hfinkel at anl.gov
Mon Sep 29 11:25:40 PDT 2014


================
Comment at: lib/Transforms/Utils/SimplifyCFG.cpp:2034
@@ +2033,3 @@
+      continue;
+    if (!I->hasOneUse() || !isSafeToSpeculativelyExecute(I, DL))
+      return false;
----------------
I don't think that the hasOneUse check here really does what you want once we allow for more than once instruction. We used to check that the single bonus instruction had one user and this user specifically was the Cond. Now you'd like to allow for some variable number of single-use instructions (regardless of a relationship to Cond). This could change behavior even when allowing only a single instruction.

I think that what you really want to do is to walk up the operand graph from Cond, accumulating instructions until you reach your limit, keeping the hasOneUse check and the check that the use is Cond for the first instruction.

================
Comment at: lib/Transforms/Utils/SimplifyCFG.cpp:2042
@@ -2041,3 +2019,2 @@
   BasicBlock::iterator CondIt = Cond; ++CondIt;
-
   // Ignore dbg intrinsics.
----------------
Please don't remove these blank lines, I think they make the code easier to read.

http://reviews.llvm.org/D5529






More information about the llvm-commits mailing list