[PATCH] D25075: [LazyValueInfo] Understand monotonically increasing loops and identity values
James Molloy via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 18 06:29:02 PDT 2016
jmolloy updated this revision to Diff 74991.
jmolloy added a comment.
Hi Philip,
Thanks again. I've separated out the first, trivial, change and isolated a testcase for it.
I'm fairly sure the cache invalidation is required, but I will make that case in a followup phab review with the rest of the code as you suggested.
Cheers,
James
Repository:
rL LLVM
https://reviews.llvm.org/D25075
Files:
lib/Analysis/LazyValueInfo.cpp
test/Transforms/CorrelatedValuePropagation/identity.ll
Index: test/Transforms/CorrelatedValuePropagation/identity.ll
===================================================================
--- /dev/null
+++ test/Transforms/CorrelatedValuePropagation/identity.ll
@@ -0,0 +1,30 @@
+; RUN: opt -S < %s -correlated-propagation | FileCheck %s
+
+; CHECK-LABEL: @f
+; CHECK: ret i32 3
+define i32 @f(i32 %n) {
+entry:
+ br label %while.cond
+
+while.cond:
+ %i = phi i32 [ 2, %entry ], [ %i, %one ], [ 3, %two ]
+ %cmp = icmp slt i32 %i, 3
+ br i1 %cmp, label %while.body, label %return
+
+while.body:
+ %call = call i32 @g(i32 1)
+ %add = add i32 %i, 6
+ %cmp3 = icmp sgt i32 %add , 6
+ br i1 %cmp3, label %one, label %two
+
+one:
+ br label %while.cond
+
+two:
+ br label %while.cond
+
+return:
+ ret i32 %i
+}
+
+declare i32 @g(i32)
Index: lib/Analysis/LazyValueInfo.cpp
===================================================================
--- lib/Analysis/LazyValueInfo.cpp
+++ lib/Analysis/LazyValueInfo.cpp
@@ -930,6 +930,11 @@
if (EdgesMissing)
continue;
+ // If this is an identity arc, we cannot be less specific now than we were
+ // before.
+ if (PhiVal == PN)
+ EdgeResult = intersect(EdgeResult, Result);
+
Result.mergeIn(EdgeResult, DL);
// If we hit overdefined, exit early. The BlockVals entry is already set
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25075.74991.patch
Type: text/x-patch
Size: 1311 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161018/4b3e4772/attachment.bin>
More information about the llvm-commits
mailing list