llvm.org GIT mirror llvm / a2f5529
[PassManager] add test to show the new PM uses -latesimplifycfg early; NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316351 91177308-0d34-0410-b5e6-96231b3b80d8 Sanjay Patel 1 year, 10 months ago
1 changed file(s) with 95 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
1 ; RUN: opt -O1 -S < %s | FileCheck %s --check-prefix=OLDPM
2 ; RUN: opt -passes='default' -S < %s | FileCheck %s --check-prefix=NEWPM
3
4 ; Don't simplify unconditional branches from empty blocks in simplifyCFG
5 ; until late in the pipeline because it can destroy canonical loop structure.
6
7 ; FIXME: The new pass manager is not limiting simplifycfg at any point in the pipeline,
8 ; so it performs a transformation before loop optimizations that is avoided in the old PM.
9
10 define i1 @PR33605(i32 %a, i32 %b, i32* %c) {
11 ; OLDPM-LABEL: @PR33605(
12 ; OLDPM-NEXT: for.body:
13 ; OLDPM-NEXT: [[OR:%.*]] = or i32 [[B:%.*]], [[A:%.*]]
14 ; OLDPM-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[C:%.*]], i64 1
15 ; OLDPM-NEXT: [[TMP0:%.*]] = load i32, i32* [[ARRAYIDX]], align 4
16 ; OLDPM-NEXT: [[CMP:%.*]] = icmp eq i32 [[OR]], [[TMP0]]
17 ; OLDPM-NEXT: br i1 [[CMP]], label [[IF_END:%.*]], label [[IF_THEN:%.*]]
18 ; OLDPM: if.then:
19 ; OLDPM-NEXT: store i32 [[OR]], i32* [[ARRAYIDX]], align 4
20 ; OLDPM-NEXT: tail call void @foo()
21 ; OLDPM-NEXT: br label [[IF_END]]
22 ; OLDPM: if.end:
23 ; OLDPM-NEXT: [[CHANGED_1_OFF0:%.*]] = phi i1 [ true, [[IF_THEN]] ], [ false, [[FOR_BODY:%.*]] ]
24 ; OLDPM-NEXT: [[TMP1:%.*]] = load i32, i32* [[C]], align 4
25 ; OLDPM-NEXT: [[CMP_1:%.*]] = icmp eq i32 [[OR]], [[TMP1]]
26 ; OLDPM-NEXT: br i1 [[CMP_1]], label [[IF_END_1:%.*]], label [[IF_THEN_1:%.*]]
27 ; OLDPM: if.then.1:
28 ; OLDPM-NEXT: store i32 [[OR]], i32* [[C]], align 4
29 ; OLDPM-NEXT: tail call void @foo()
30 ; OLDPM-NEXT: br label [[IF_END_1]]
31 ; OLDPM: if.end.1:
32 ; OLDPM-NEXT: [[CHANGED_1_OFF0_1:%.*]] = phi i1 [ true, [[IF_THEN_1]] ], [ [[CHANGED_1_OFF0]], [[IF_END]] ]
33 ; OLDPM-NEXT: ret i1 [[CHANGED_1_OFF0_1]]
34 ;
35 ; NEWPM-LABEL: @PR33605(
36 ; NEWPM-NEXT: entry:
37 ; NEWPM-NEXT: [[OR:%.*]] = or i32 [[B:%.*]], [[A:%.*]]
38 ; NEWPM-NEXT: br label [[FOR_COND_OUTER:%.*]]
39 ; NEWPM: for.cond.outer:
40 ; NEWPM-NEXT: [[I_0_PH:%.*]] = phi i32 [ [[DEC:%.*]], [[IF_THEN:%.*]] ], [ 2, [[ENTRY:%.*]] ]
41 ; NEWPM-NEXT: [[CHANGED_0_OFF0_PH:%.*]] = phi i1 [ true, [[IF_THEN]] ], [ false, [[ENTRY]] ]
42 ; NEWPM-NEXT: br label [[FOR_COND:%.*]]
43 ; NEWPM: for.cond:
44 ; NEWPM-NEXT: [[I_0:%.*]] = phi i32 [ [[DEC]], [[FOR_BODY:%.*]] ], [ [[I_0_PH]], [[FOR_COND_OUTER]] ]
45 ; NEWPM-NEXT: [[DEC]] = add nsw i32 [[I_0]], -1
46 ; NEWPM-NEXT: [[TOBOOL:%.*]] = icmp eq i32 [[I_0]], 0
47 ; NEWPM-NEXT: br i1 [[TOBOOL]], label [[FOR_COND_CLEANUP:%.*]], label [[FOR_BODY]]
48 ; NEWPM: for.cond.cleanup:
49 ; NEWPM-NEXT: ret i1 [[CHANGED_0_OFF0_PH]]
50 ; NEWPM: for.body:
51 ; NEWPM-NEXT: [[IDXPROM:%.*]] = sext i32 [[DEC]] to i64
52 ; NEWPM-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[C:%.*]], i64 [[IDXPROM]]
53 ; NEWPM-NEXT: [[TMP0:%.*]] = load i32, i32* [[ARRAYIDX]], align 4
54 ; NEWPM-NEXT: [[CMP:%.*]] = icmp eq i32 [[OR]], [[TMP0]]
55 ; NEWPM-NEXT: br i1 [[CMP]], label [[FOR_COND]], label [[IF_THEN]]
56 ; NEWPM: if.then:
57 ; NEWPM-NEXT: store i32 [[OR]], i32* [[ARRAYIDX]], align 4
58 ; NEWPM-NEXT: tail call void @foo()
59 ; NEWPM-NEXT: br label [[FOR_COND_OUTER]]
60 ;
61 entry:
62 br label %for.cond
63
64 for.cond:
65 %i.0 = phi i32 [ 2, %entry ], [ %dec, %if.end ]
66 %changed.0.off0 = phi i1 [ false, %entry ], [ %changed.1.off0, %if.end ]
67 %dec = add nsw i32 %i.0, -1
68 %tobool = icmp eq i32 %i.0, 0
69 br i1 %tobool, label %for.cond.cleanup, label %for.body
70
71 for.cond.cleanup:
72 %changed.0.off0.lcssa = phi i1 [ %changed.0.off0, %for.cond ]
73 ret i1 %changed.0.off0.lcssa
74
75 for.body:
76 %or = or i32 %a, %b
77 %idxprom = sext i32 %dec to i64
78 %arrayidx = getelementptr inbounds i32, i32* %c, i64 %idxprom
79 %0 = load i32, i32* %arrayidx, align 4
80 %cmp = icmp eq i32 %or, %0
81 br i1 %cmp, label %if.end, label %if.then
82
83 if.then:
84 store i32 %or, i32* %arrayidx, align 4
85 call void @foo()
86 br label %if.end
87
88 if.end:
89 %changed.1.off0 = phi i1 [ true, %if.then ], [ %changed.0.off0, %for.body ]
90 br label %for.cond
91 }
92
93 declare void @foo()
94