llvm.org GIT mirror llvm / 29492fb
NewGVN: Make sure we don't incorrectly use PredicateInfo when doing PHI of ops Summary: When we backtranslate expressions, we can't use the predicateinfo, since we are evaluating them in a different context. Reviewers: davide, mcrosier Subscribers: sanjoy, Prazek, llvm-commits Differential Revision: https://reviews.llvm.org/D37174 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312352 91177308-0d34-0410-b5e6-96231b3b80d8 Daniel Berlin 2 years ago
2 changed file(s) with 54 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
17811781 if (PI == LastPredInfo)
17821782 continue;
17831783 LastPredInfo = PI;
1784
1785 // TODO: Along the false edge, we may know more things too, like icmp of
1784 // In phi of ops cases, we may have predicate info that we are evaluating
1785 // in a different context.
1786 if (!DT->dominates(PBranch->To, getBlockForValue(I)))
1787 continue;
1788 // TODO: Along the false edge, we may know more things too, like
1789 // icmp of
17861790 // same operands is false.
1787 // TODO: We only handle actual comparison conditions below, not and/or.
1791 // TODO: We only handle actual comparison conditions below, not
1792 // and/or.
17881793 auto *BranchCond = dyn_cast(PBranch->Condition);
17891794 if (!BranchCond)
17901795 continue;
25322537 // and make sure anything that tries to add it's DFS number is
25332538 // redirected to the instruction we are making a phi of ops
25342539 // for.
2540 TempToBlock.insert({ValueOp, PredBB});
25352541 InstrDFS.insert({ValueOp, IDFSNum});
25362542 const Expression *E = performSymbolicEvaluation(ValueOp, Visited);
25372543 InstrDFS.erase(ValueOp);
25382544 AllTempInstructions.erase(ValueOp);
25392545 ValueOp->deleteValue();
2546 TempToBlock.erase(ValueOp);
25402547 if (MemAccess)
25412548 TempToMemory.erase(ValueOp);
25422549 if (!E)
0 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
1 ; RUN: opt < %s -newgvn -enable-phi-of-ops=true -S | FileCheck %s
2 ;; Make sure we don't incorrectly use predicateinfo to simplify phi of ops cases
3 source_filename = "pr34135.ll"
4
5 define void @snork(i32 %arg) {
6 ; CHECK-LABEL: @snork(
7 ; CHECK-NEXT: bb:
8 ; CHECK-NEXT: [[TMP:%.*]] = sext i32 [[ARG:%.*]] to i64
9 ; CHECK-NEXT: br label [[BB1:%.*]]
10 ; CHECK: bb1:
11 ; CHECK-NEXT: [[TMP2:%.*]] = phi i64 [ 0, [[BB:%.*]] ], [ [[TMP3:%.*]], [[BB1]] ]
12 ; CHECK-NEXT: [[TMP3]] = add i64 [[TMP2]], 1
13 ; CHECK-NEXT: [[TMP4:%.*]] = icmp slt i64 [[TMP3]], [[TMP]]
14 ; CHECK-NEXT: br i1 [[TMP4]], label [[BB1]], label [[BB7:%.*]]
15 ; CHECK: bb5:
16 ; CHECK-NEXT: [[TMP6:%.*]] = icmp sgt i64 [[TMP]], 1
17 ; CHECK-NEXT: br i1 [[TMP6]], label [[BB7]], label [[BB9:%.*]]
18 ; CHECK: bb7:
19 ; CHECK-NEXT: br label [[BB5:%.*]]
20 ; CHECK: bb9:
21 ; CHECK-NEXT: unreachable
22 ;
23 bb:
24 %tmp = sext i32 %arg to i64
25 br label %bb1
26
27 bb1: ; preds = %bb1, %bb
28 %tmp2 = phi i64 [ 0, %bb ], [ %tmp3, %bb1 ]
29 %tmp3 = add i64 %tmp2, 1
30 %tmp4 = icmp slt i64 %tmp3, %tmp
31 br i1 %tmp4, label %bb1, label %bb7
32
33 bb5: ; preds = %bb7
34 %tmp6 = icmp sgt i64 %tmp8, 1
35 br i1 %tmp6, label %bb7, label %bb9
36
37 bb7: ; preds = %bb5, %bb1
38 %tmp8 = phi i64 [ undef, %bb5 ], [ %tmp, %bb1 ]
39 br label %bb5
40
41 bb9: ; preds = %bb5
42 unreachable
43 }