[PATCH] D42179: [NewGVN] Re-evaluate phi of ops after moving an instr to new class
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 17 06:30:28 PST 2018
fhahn created this revision.
fhahn added reviewers: dberlin, davide, mcrosier.
Herald added a subscriber: Prazek.
[NewGVN] After moving an instr to a new class, re-evaluate phi of ops.
After moving an instruction to a new class, its leader could have
changed, which means we might be able to simplify phi of ops involving
it as expression.
Repository:
rL LLVM
https://reviews.llvm.org/D42179
Files:
lib/Transforms/Scalar/NewGVN.cpp
test/Transforms/NewGVN/pr35074-phi-of-ops-leader-change-after-moving-I.ll
Index: test/Transforms/NewGVN/pr35074-phi-of-ops-leader-change-after-moving-I.ll
===================================================================
--- /dev/null
+++ test/Transforms/NewGVN/pr35074-phi-of-ops-leader-change-after-moving-I.ll
@@ -0,0 +1,36 @@
+; RUN: opt < %s -newgvn -S | FileCheck %s
+
+; CHECK-LABEL: for.cond:
+; CHECK-NEXT: %phiofops = phi i32 [ 0, %entry ], [ %y.0, %for.inc6 ]
+; CHECK-NEXT: %y.0 = phi i32 [ 1, %entry ], [ %inc7, %for.inc6 ]
+
+; CHECK-LABEL: for.body.lr.ph:
+; CHECK-NEXT: %cmp = icmp ugt i32 %phiofops, %y.0
+
+define void @test(i32 %this) {
+entry:
+ br label %for.cond
+
+for.cond: ; preds = %for.inc6, %entry
+ %y.0 = phi i32 [ 1, %entry ], [ %inc7, %for.inc6 ]
+ br i1 undef, label %for.inc6, label %for.body.lr.ph
+
+for.body.lr.ph: ; preds = %for.cond
+ %sub = add nsw i32 %y.0, -1
+ %cmp = icmp ugt i32 %sub, %y.0
+ br i1 %cmp, label %for.end, label %for.body4.1
+
+for.end: ; preds = %for.body4.1, %for.body.lr.ph
+ ret void
+
+for.inc6: ; preds = %for.cond
+ %inc7 = add nuw nsw i32 %y.0, 1
+ br label %for.cond
+
+for.body4.1: ; preds = %for.body.lr.ph
+ %inc.1 = add nuw nsw i32 %y.0, 1
+ tail call void @_blah(i32 %inc.1)
+ br label %for.end
+}
+
+declare void @_blah(i32)
Index: lib/Transforms/Scalar/NewGVN.cpp
===================================================================
--- lib/Transforms/Scalar/NewGVN.cpp
+++ lib/Transforms/Scalar/NewGVN.cpp
@@ -2409,6 +2409,9 @@
moveValueToNewCongruenceClass(I, E, IClass, EClass);
markPhiOfOpsChanged(E);
}
+ // After moving I to the new class, its leader could have changed, which
+ // means that we might be able to simplify phi of ops involving it.
+ markPhiOfOpsChanged(createVariableOrConstant(I));
markUsersTouched(I);
if (MemoryAccess *MA = getMemoryAccess(I))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42179.130169.patch
Type: text/x-patch
Size: 2015 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180117/c8371c52/attachment.bin>
More information about the llvm-commits
mailing list