[PATCH] D12418: Distribute the weight on the edge from switch to default statement to edges generated in lowering switch.

David Li via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 28 12:32:36 PDT 2015


davidxl added inline comments.

================
Comment at: test/CodeGen/X86/switch-edge-weight.ll:35
@@ +34,3 @@
+; CHECK: BB#0:
+; CHECK: Successors according to CFG: BB#4(65) BB#5(25)
+; CHECK: BB#5:
----------------
hans wrote:
> It would be super nice if these tests could have comments explaining why these weights are in fact the correct ones.
> 
> I don't know if this is a reasonable expectation or not, just throwing it out there - it would make it easier for someone reading the test to verify what's going on.
> 
> In this test it seems we'll have four ranges, {1}, {155-159}, {1134} and {1140}. I think the pivot here will be 1134, so the weight on the left is 10+50+10/2=65 and on the right is 10+10+10/5=25, so that matches my expectations. But why are the weights so low below? Shouldn't the edge from the 155-159 range to sw.bb have more weight?
The weight distribution makes sense to me.

BB#5 has as test ' %x == 1140'. Since BB#5's weight is 25 and 1140's weight is 10, so this leaves BB#6 15.

BB#6 has check %x == 1134. One successor is 10, and the remaining (part of the default) is 5.


http://reviews.llvm.org/D12418





More information about the llvm-commits mailing list