[PATCH] D12513: Update edge weights properly when merging blocks in if-conversion.

Cong Hou via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 1 14:34:17 PDT 2015


congh added a comment.

In http://reviews.llvm.org/D12513#237639, @davidxl wrote:

> I'd like profile update to be isolated in its own helper function. Have some examples in the comments (like in the test case) -- the example should  show cfg before and after. The parameters also need to be documented.


It is difficult to isolate profile update here as the profile data is needed when adding successors.

I have added a CFG example to the comment in this function. Some variables are also documented.


================
Comment at: lib/CodeGen/IfConversion.cpp:1701
@@ +1700,3 @@
+        std::find(ToBBI.BB->succ_begin(), ToBBI.BB->succ_end(), FromBBI.BB), 0);
+    To2FromWeight = MBPI->getEdgeWeight(ToBBI.BB, FromBBI.BB);
+    SumWeight = MBPI->getSumForBlock(FromBBI.BB, WeightScale);
----------------
davidxl wrote:
> Should it be zero?
I made a mistake here: I should get To2FromWeight before the edge weight is set to zero. Need to switch this statement with the one above.

================
Comment at: lib/CodeGen/IfConversion.cpp:1736
@@ +1735,3 @@
+      // NewWeight.
+      if (ToBBI.BB->isSuccessor(Succ))
+        ToBBI.BB->setSuccWeight(
----------------
davidxl wrote:
> Do you have example of this case?
Yes. The test case in test/CodeGen/ARM/ifcvt-iter-indbr.ll covers this case. 


http://reviews.llvm.org/D12513





More information about the llvm-commits mailing list