llvm.org GIT mirror llvm / e6be55f
PredicateInfo: Don't insert conditional info when a conditional branch jumps to the same target regardless of condition git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305416 91177308-0d34-0410-b5e6-96231b3b80d8 Daniel Berlin 2 years ago
3 changed file(s) with 164 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
458458 BasicBlock *BranchBB = DTN->getBlock();
459459 if (auto *BI = dyn_cast(BranchBB->getTerminator())) {
460460 if (!BI->isConditional())
461 continue;
462 // Can't insert conditional information if they all go to the same place.
463 if (BI->getSuccessor(0) == BI->getSuccessor(1))
461464 continue;
462465 processBranch(BI, BranchBB, OpsToRename);
463466 } else if (auto *SI = dyn_cast(BranchBB->getTerminator())) {
0 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
1 ; RUN: opt -print-predicateinfo -analyze < %s 2>&1 | FileCheck %s
2 ; Don't insert predicate info for conditions with a single target.
3 @a = global i32 1, align 4
4 @d = common global i32 0, align 4
5 @c = common global i32 0, align 4
6 @b = common global i32 0, align 4
7 @e = common global i32 0, align 4
8
9 define i32 @main() {
10 ; CHECK-LABEL: @main(
11 ; CHECK-NEXT: [[TMP1:%.*]] = load i32, i32* @d, align 4
12 ; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP1]], 0
13 ; CHECK-NEXT: br i1 [[TMP2]], label [[TMP3:%.*]], label [[TMP13:%.*]]
14 ; CHECK: [[TMP4:%.*]] = load i32, i32* @a, align 4
15 ; CHECK-NEXT: [[TMP5:%.*]] = load i32, i32* @c, align 4
16 ; CHECK-NEXT: [[TMP6:%.*]] = icmp slt i32 [[TMP5]], 1
17 ; CHECK-NEXT: br i1 [[TMP6]], label [[TMP7:%.*]], label [[TMP9:%.*]]
18 ; CHECK: [[TMP8:%.*]] = icmp eq i32 [[TMP4]], 0
19 ; CHECK-NEXT: br i1 [[TMP8]], label [[TMP9]], label [[TMP9]]
20 ; CHECK: [[DOT0:%.*]] = phi i32 [ [[TMP4]], [[TMP7]] ], [ [[TMP4]], [[TMP7]] ], [ [[DOT1:%.*]], [[TMP13]] ], [ [[TMP4]], [[TMP3]] ]
21 ; CHECK-NEXT: [[TMP10:%.*]] = load i32, i32* @b, align 4
22 ; CHECK-NEXT: [[TMP11:%.*]] = sdiv i32 [[TMP10]], [[DOT0]]
23 ; CHECK-NEXT: [[TMP12:%.*]] = icmp eq i32 [[TMP11]], 0
24 ; CHECK-NEXT: br i1 [[TMP12]], label [[TMP13]], label [[TMP13]]
25 ; CHECK: [[DOT1]] = phi i32 [ [[DOT0]], [[TMP9]] ], [ [[DOT0]], [[TMP9]] ], [ undef, [[TMP0:%.*]] ]
26 ; CHECK-NEXT: [[TMP14:%.*]] = load i32, i32* @e, align 4
27 ; CHECK-NEXT: [[TMP15:%.*]] = icmp eq i32 [[TMP14]], 0
28 ; CHECK-NEXT: br i1 [[TMP15]], label [[TMP16:%.*]], label [[TMP9]]
29 ; CHECK: ret i32 0
30 ;
31 %1 = load i32, i32* @d, align 4
32 %2 = icmp eq i32 %1, 0
33 br i1 %2, label %3, label %13
34
35 ;
36 %4 = load i32, i32* @a, align 4
37 %5 = load i32, i32* @c, align 4
38 %6 = icmp slt i32 %5, 1
39 br i1 %6, label %7, label %9
40
41 ;
42 %8 = icmp eq i32 %4, 0
43 br i1 %8, label %9, label %9
44
45 ;
46 %.0 = phi i32 [ %4, %7 ], [ %4, %7 ], [ %.1, %13 ], [ %4, %3 ]
47 %10 = load i32, i32* @b, align 4
48 %11 = sdiv i32 %10, %.0
49 %12 = icmp eq i32 %11, 0
50 br i1 %12, label %13, label %13
51
52 ;
53 %.1 = phi i32 [ %.0, %9 ], [ %.0, %9 ], [ undef, %0 ]
54 %14 = load i32, i32* @e, align 4
55 %15 = icmp eq i32 %14, 0
56 br i1 %15, label %16, label %9
57
58 ;
59 ret i32 0
60 }
61
62 ; Function Attrs: argmemonly nounwind
63 declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture)
64
65 ; Function Attrs: argmemonly nounwind
66 declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture)
67
0 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
1 ; RUN: opt -print-predicateinfo -analyze < %s 2>&1 | FileCheck %s
2 ; Don't insert predicate info for conditions with a single target.
3 @a = global i32 6, align 4
4 @c = global i32 -1, align 4
5 @e = common global i32 0, align 4
6 @.str = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
7 @d = common global i32 0, align 4
8 @b = common global [6 x i32] zeroinitializer, align 16
9
10 ; Function Attrs: nounwind ssp uwtable
11 define i32 @main() {
12 ; CHECK-LABEL: @main(
13 ; CHECK-NEXT: store i32 6, i32* @e, align 4
14 ; CHECK-NEXT: br label [[TMP1:%.*]]
15 ; CHECK: [[TMP2:%.*]] = load i32, i32* @d, align 4
16 ; CHECK-NEXT: [[TMP3:%.*]] = sext i32 [[TMP2]] to i64
17 ; CHECK-NEXT: [[TMP4:%.*]] = getelementptr inbounds [6 x i32], [6 x i32]* @b, i64 0, i64 [[TMP3]]
18 ; CHECK-NEXT: [[TMP5:%.*]] = load i32, i32* [[TMP4]], align 4
19 ; CHECK-NEXT: [[TMP6:%.*]] = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 [[TMP5]])
20 ; CHECK-NEXT: [[TMP7:%.*]] = load i32, i32* @a, align 4
21 ; CHECK-NEXT: [[TMP8:%.*]] = icmp eq i32 [[TMP7]], 0
22 ; CHECK-NEXT: br i1 [[TMP8]], label %thread-pre-split, label [[TMP9:%.*]]
23 ; CHECK: [[TMP10:%.*]] = load i32, i32* @e, align 4
24 ; CHECK-NEXT: [[TMP11:%.*]] = icmp eq i32 [[TMP10]], 0
25 ; CHECK-NEXT: br i1 [[TMP11]], label [[TMP12:%.*]], label [[TMP12]]
26 ; CHECK: thread-pre-split:
27 ; CHECK-NEXT: [[DOTPR:%.*]] = load i32, i32* @e, align 4
28 ; CHECK-NEXT: br label [[TMP12]]
29 ; CHECK: [[TMP13:%.*]] = phi i32 [ [[DOTPR]], %thread-pre-split ], [ [[TMP10]], [[TMP9]] ], [ [[TMP10]], [[TMP9]] ]
30 ; CHECK-NEXT: [[TMP14:%.*]] = icmp ne i32 [[TMP13]], 0
31 ; CHECK-NEXT: br i1 [[TMP14]], label [[TMP15:%.*]], label [[TMP15]]
32 ; CHECK: br i1 [[TMP14]], label [[TMP16:%.*]], label [[TMP17:%.*]]
33 ; CHECK: br label [[TMP17]]
34 ; CHECK: [[DOT0:%.*]] = phi i32 [ 1, [[TMP16]] ], [ -1, [[TMP15]] ]
35 ; CHECK-NEXT: [[TMP18:%.*]] = and i32 [[DOT0]], 8693
36 ; CHECK-NEXT: [[TMP19:%.*]] = load i32, i32* @c, align 4
37 ; CHECK-NEXT: [[TMP20:%.*]] = xor i32 [[TMP18]], [[TMP19]]
38 ; CHECK-NEXT: [[TMP21:%.*]] = xor i32 [[TMP20]], -1
39 ; CHECK-NEXT: store i32 [[TMP21]], i32* @d, align 4
40 ; CHECK-NEXT: [[TMP22:%.*]] = icmp slt i32 [[TMP20]], -2
41 ; CHECK-NEXT: br i1 [[TMP22]], label [[TMP1]], label [[TMP23:%.*]]
42 ; CHECK: ret i32 0
43 ;
44 store i32 6, i32* @e, align 4
45 br label %1
46
47 ;
48 %2 = load i32, i32* @d, align 4
49 %3 = sext i32 %2 to i64
50 %4 = getelementptr inbounds [6 x i32], [6 x i32]* @b, i64 0, i64 %3
51 %5 = load i32, i32* %4, align 4
52 %6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %5) #2
53 %7 = load i32, i32* @a, align 4
54 %8 = icmp eq i32 %7, 0
55 br i1 %8, label %thread-pre-split, label %9
56
57 ;
58 %10 = load i32, i32* @e, align 4
59 %11 = icmp eq i32 %10, 0
60 br i1 %11, label %12, label %12
61
62 thread-pre-split: ; preds = %1
63 %.pr = load i32, i32* @e, align 4
64 br label %12
65
66 ;
67 %13 = phi i32 [ %.pr, %thread-pre-split ], [ %10, %9 ], [ %10, %9 ]
68 %14 = icmp ne i32 %13, 0
69 br i1 %14, label %15, label %15
70
71 ;
72 br i1 %14, label %16, label %17
73
74 ;
75 br label %17
76
77 ;
78 %.0 = phi i32 [ 1, %16 ], [ -1, %15 ]
79 %18 = and i32 %.0, 8693
80 %19 = load i32, i32* @c, align 4
81 %20 = xor i32 %18, %19
82 %21 = xor i32 %20, -1
83 store i32 %21, i32* @d, align 4
84 %22 = icmp slt i32 %20, -2
85 br i1 %22, label %1, label %23
86
87 ;
88 ret i32 0
89 }
90
91 declare i32 @printf(i8*, ...)
92