[PATCH] D40891: Revert a change in propagateMassToSuccessors that summed redundant edges n^2 times
Andrew Scheidecker via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 7 15:54:05 PST 2017
AndrewScheidecker updated this revision to Diff 126063.
AndrewScheidecker retitled this revision from "Fix accidentally quadratic time in BlockFrequencyInfoImpl::propagateMassToSuccessors" to "Revert a change in propagateMassToSuccessors that summed redundant edges n^2 times".
AndrewScheidecker edited the summary of this revision.
AndrewScheidecker added a comment.
Added a test that produces different results with and without this fix
Repository:
rL LLVM
https://reviews.llvm.org/D40891
Files:
include/llvm/Analysis/BlockFrequencyInfoImpl.h
test/Analysis/BlockFrequencyInfo/redundant_edges.ll
Index: test/Analysis/BlockFrequencyInfo/redundant_edges.ll
===================================================================
--- /dev/null
+++ test/Analysis/BlockFrequencyInfo/redundant_edges.ll
@@ -0,0 +1,35 @@
+; RUN: opt < %s -analyze -block-freq | FileCheck %s
+; RUN: opt < %s -analyze -lazy-block-freq | FileCheck %s
+; RUN: opt < %s -passes='print<block-freq>' -disable-output 2>&1 | FileCheck %s
+
+define i32 @test1(i32) {
+; CHECK-LABEL: Printing analysis {{.*}} for function 'test1':
+; CHECK-NEXT: block-frequency-info: test1
+; CHECK-NEXT: entry: float = 1.0, int = [[ENTRY:[0-9]+]]
+entry:
+ br label %loop
+
+; CHECK-NEXT: loop: float = 32.0
+loop:
+ %i = phi i32 [%0, %entry], [%i.next, %blockEnd]
+ switch i32 %i, label %blockEnd [
+ i32 0, label %return
+ i32 1, label %return
+ i32 2, label %return
+ i32 3, label %return
+ i32 4, label %return
+ i32 5, label %return
+ i32 6, label %return
+ i32 7, label %return
+ ]
+
+; CHECK-NEXT: blockEnd: float = 31.0
+blockEnd:
+ %i.next = add i32 %i, 1
+ br label %loop
+
+; CHECK-NEXT: return: float = 1.0
+return:
+ %ret = phi i32 [ 0, %loop ], [ 0, %loop ], [ 0, %loop ], [ 0, %loop ], [ 0, %loop ], [ 0, %loop ], [ 0, %loop ], [ 0, %loop ]
+ ret i32 %ret
+}
Index: include/llvm/Analysis/BlockFrequencyInfoImpl.h
===================================================================
--- include/llvm/Analysis/BlockFrequencyInfoImpl.h
+++ include/llvm/Analysis/BlockFrequencyInfoImpl.h
@@ -1315,9 +1315,12 @@
return false;
} else {
const BlockT *BB = getBlock(Node);
- for (const auto Succ : children<const BlockT *>(BB))
- if (!addToDist(Dist, OuterLoop, Node, getNode(Succ),
- getWeightFromBranchProb(BPI->getEdgeProbability(BB, Succ))))
+ for (auto SuccI = GraphTraits<const BlockT *>::child_begin(BB),
+ SuccE = GraphTraits<const BlockT *>::child_end(BB);
+ SuccI != SuccE; ++SuccI)
+ if (!addToDist(
+ Dist, OuterLoop, Node, getNode(*SuccI),
+ getWeightFromBranchProb(BPI->getEdgeProbability(BB, SuccI))))
// Irreducible backedge.
return false;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40891.126063.patch
Type: text/x-patch
Size: 2166 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171207/d424505a/attachment.bin>
More information about the llvm-commits
mailing list