1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -gvn -gvn-max-block-speculations=1 -S | FileCheck -check-prefix=PRE %s
3 ; RUN: opt < %s -gvn -gvn-max-block-speculations=0 -S | FileCheck -check-prefix=CHECK %s
5 define i32 @loadpre_opportunity(i32** %arg, i1 %arg1, i1 %arg2, i1 %arg3) {
6 ; PRE-LABEL: @loadpre_opportunity(
8 ; PRE-NEXT: [[I:%.*]] = load i32*, i32** [[ARG:%.*]], align 8
9 ; PRE-NEXT: [[I6:%.*]] = call i32 @use(i32* [[I]])
10 ; PRE-NEXT: br label [[BB11:%.*]]
12 ; PRE-NEXT: [[I8:%.*]] = phi i32* [ [[I8_PRE:%.*]], [[BB17_BB7_CRIT_EDGE:%.*]] ], [ [[I81:%.*]], [[BB11]] ]
13 ; PRE-NEXT: [[I10:%.*]] = call i32 @use(i32* [[I8]])
14 ; PRE-NEXT: br label [[BB11]]
16 ; PRE-NEXT: [[I81]] = phi i32* [ [[I]], [[BB:%.*]] ], [ [[I8]], [[BB7:%.*]] ]
17 ; PRE-NEXT: [[I12:%.*]] = phi i32 [ [[I6]], [[BB]] ], [ [[I10]], [[BB7]] ]
18 ; PRE-NEXT: br i1 [[ARG1:%.*]], label [[BB7]], label [[BB13:%.*]]
20 ; PRE-NEXT: call void @somecall()
21 ; PRE-NEXT: br i1 [[ARG2:%.*]], label [[BB14:%.*]], label [[BB17:%.*]]
23 ; PRE-NEXT: br label [[BB15:%.*]]
25 ; PRE-NEXT: br i1 [[ARG3:%.*]], label [[BB16:%.*]], label [[BB15]]
27 ; PRE-NEXT: br label [[BB17]]
29 ; PRE-NEXT: [[I18:%.*]] = call i1 @cond()
30 ; PRE-NEXT: br i1 [[I18]], label [[BB17_BB7_CRIT_EDGE]], label [[BB19:%.*]]
31 ; PRE: bb17.bb7_crit_edge:
32 ; PRE-NEXT: [[I8_PRE]] = load i32*, i32** [[ARG]], align 8
33 ; PRE-NEXT: br label [[BB7]]
35 ; PRE-NEXT: ret i32 [[I12]]
37 ; CHECK-LABEL: @loadpre_opportunity(
39 ; CHECK-NEXT: [[I:%.*]] = load i32*, i32** [[ARG:%.*]], align 8
40 ; CHECK-NEXT: [[I6:%.*]] = call i32 @use(i32* [[I]])
41 ; CHECK-NEXT: br label [[BB11:%.*]]
43 ; CHECK-NEXT: [[I8:%.*]] = load i32*, i32** [[ARG]], align 8
44 ; CHECK-NEXT: [[I10:%.*]] = call i32 @use(i32* [[I8]])
45 ; CHECK-NEXT: br label [[BB11]]
47 ; CHECK-NEXT: [[I12:%.*]] = phi i32 [ [[I6]], [[BB:%.*]] ], [ [[I10]], [[BB7:%.*]] ]
48 ; CHECK-NEXT: br i1 [[ARG1:%.*]], label [[BB7]], label [[BB13:%.*]]
50 ; CHECK-NEXT: call void @somecall()
51 ; CHECK-NEXT: br i1 [[ARG2:%.*]], label [[BB14:%.*]], label [[BB17:%.*]]
53 ; CHECK-NEXT: br label [[BB15:%.*]]
55 ; CHECK-NEXT: br i1 [[ARG3:%.*]], label [[BB16:%.*]], label [[BB15]]
57 ; CHECK-NEXT: br label [[BB17]]
59 ; CHECK-NEXT: [[I18:%.*]] = call i1 @cond()
60 ; CHECK-NEXT: br i1 [[I18]], label [[BB7]], label [[BB19:%.*]]
62 ; CHECK-NEXT: ret i32 [[I12]]
65 %i = load i32*, i32** %arg, align 8
66 %i4 = getelementptr inbounds i32, i32* %i, i64 0
70 %i6 = call i32 @use(i32* %i4)
74 %i8 = load i32*, i32** %arg, align 8
75 %i9 = getelementptr inbounds i32, i32* %i8, i64 0
76 %i10 = call i32 @use(i32* %i9)
80 %i12 = phi i32 [ %i6, %bb5 ], [ %i10, %bb7 ]
81 br i1 %arg1, label %bb7, label %bb13
85 br i1 %arg2, label %bb14, label %bb17
91 br i1 %arg3, label %bb16, label %bb15
97 %i18 = call i1 @cond()
98 br i1 %i18, label %bb7, label %bb19
104 declare void @somecall()
105 declare i32 @use(i32*) readnone
106 declare i1 @cond() readnone