|
1 | 1 | ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
2 |
| -; RUN: opt -O1 -S < %s | FileCheck %s --check-prefix=ALL --check-prefix=OLDPM |
3 |
| -; RUN: opt -passes='default<O1>' -S < %s | FileCheck %s --check-prefix=ALL --check-prefix=NEWPM |
4 |
| - |
5 |
| -declare void @foo() |
| 2 | +; RUN: opt -O1 -S < %s | FileCheck %s --check-prefix=OLDPM |
| 3 | +; RUN: opt -passes='default<O1>' -S < %s | FileCheck %s --check-prefix=NEWPM |
6 | 4 |
|
7 | 5 | ; Don't simplify unconditional branches from empty blocks in simplifyCFG
|
8 | 6 | ; until late in the pipeline because it can destroy canonical loop structure.
|
9 | 7 |
|
| 8 | +; FIXME: The new pass manager is not limiting simplifycfg at any point in the pipeline, |
| 9 | +; so it performs a transformation before loop optimizations that is avoided in the old PM. |
| 10 | + |
10 | 11 | define i1 @PR33605(i32 %a, i32 %b, i32* %c) {
|
11 |
| -; ALL-LABEL: @PR33605( |
12 |
| -; ALL-NEXT: for.body: |
13 |
| -; ALL-NEXT: [[OR:%.*]] = or i32 [[B:%.*]], [[A:%.*]] |
14 |
| -; ALL-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[C:%.*]], i64 1 |
15 |
| -; ALL-NEXT: [[TMP0:%.*]] = load i32, i32* [[ARRAYIDX]], align 4 |
16 |
| -; ALL-NEXT: [[CMP:%.*]] = icmp eq i32 [[OR]], [[TMP0]] |
17 |
| -; ALL-NEXT: br i1 [[CMP]], label [[IF_END:%.*]], label [[IF_THEN:%.*]] |
18 |
| -; ALL: if.then: |
19 |
| -; ALL-NEXT: store i32 [[OR]], i32* [[ARRAYIDX]], align 4 |
20 |
| -; ALL-NEXT: tail call void @foo() |
21 |
| -; ALL-NEXT: br label [[IF_END]] |
22 |
| -; ALL: if.end: |
23 |
| -; ALL-NEXT: [[CHANGED_1_OFF0:%.*]] = phi i1 [ true, [[IF_THEN]] ], [ false, [[FOR_BODY:%.*]] ] |
24 |
| -; ALL-NEXT: [[TMP1:%.*]] = load i32, i32* [[C]], align 4 |
25 |
| -; ALL-NEXT: [[CMP_1:%.*]] = icmp eq i32 [[OR]], [[TMP1]] |
26 |
| -; ALL-NEXT: br i1 [[CMP_1]], label [[IF_END_1:%.*]], label [[IF_THEN_1:%.*]] |
27 |
| -; ALL: if.then.1: |
28 |
| -; ALL-NEXT: store i32 [[OR]], i32* [[C]], align 4 |
29 |
| -; ALL-NEXT: tail call void @foo() |
30 |
| -; ALL-NEXT: br label [[IF_END_1]] |
31 |
| -; ALL: if.end.1: |
32 |
| -; ALL-NEXT: [[CHANGED_1_OFF0_1:%.*]] = phi i1 [ true, [[IF_THEN_1]] ], [ [[CHANGED_1_OFF0]], [[IF_END]] ] |
33 |
| -; ALL-NEXT: ret i1 [[CHANGED_1_OFF0_1]] |
| 12 | +; OLDPM-LABEL: @PR33605( |
| 13 | +; OLDPM-NEXT: for.body: |
| 14 | +; OLDPM-NEXT: [[OR:%.*]] = or i32 [[B:%.*]], [[A:%.*]] |
| 15 | +; OLDPM-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[C:%.*]], i64 1 |
| 16 | +; OLDPM-NEXT: [[TMP0:%.*]] = load i32, i32* [[ARRAYIDX]], align 4 |
| 17 | +; OLDPM-NEXT: [[CMP:%.*]] = icmp eq i32 [[OR]], [[TMP0]] |
| 18 | +; OLDPM-NEXT: br i1 [[CMP]], label [[IF_END:%.*]], label [[IF_THEN:%.*]] |
| 19 | +; OLDPM: if.then: |
| 20 | +; OLDPM-NEXT: store i32 [[OR]], i32* [[ARRAYIDX]], align 4 |
| 21 | +; OLDPM-NEXT: tail call void @foo() |
| 22 | +; OLDPM-NEXT: br label [[IF_END]] |
| 23 | +; OLDPM: if.end: |
| 24 | +; OLDPM-NEXT: [[CHANGED_1_OFF0:%.*]] = phi i1 [ true, [[IF_THEN]] ], [ false, [[FOR_BODY:%.*]] ] |
| 25 | +; OLDPM-NEXT: [[TMP1:%.*]] = load i32, i32* [[C]], align 4 |
| 26 | +; OLDPM-NEXT: [[CMP_1:%.*]] = icmp eq i32 [[OR]], [[TMP1]] |
| 27 | +; OLDPM-NEXT: br i1 [[CMP_1]], label [[IF_END_1:%.*]], label [[IF_THEN_1:%.*]] |
| 28 | +; OLDPM: if.then.1: |
| 29 | +; OLDPM-NEXT: store i32 [[OR]], i32* [[C]], align 4 |
| 30 | +; OLDPM-NEXT: tail call void @foo() |
| 31 | +; OLDPM-NEXT: br label [[IF_END_1]] |
| 32 | +; OLDPM: if.end.1: |
| 33 | +; OLDPM-NEXT: [[CHANGED_1_OFF0_1:%.*]] = phi i1 [ true, [[IF_THEN_1]] ], [ [[CHANGED_1_OFF0]], [[IF_END]] ] |
| 34 | +; OLDPM-NEXT: ret i1 [[CHANGED_1_OFF0_1]] |
| 35 | +; |
| 36 | +; NEWPM-LABEL: @PR33605( |
| 37 | +; NEWPM-NEXT: entry: |
| 38 | +; NEWPM-NEXT: [[OR:%.*]] = or i32 [[B:%.*]], [[A:%.*]] |
| 39 | +; NEWPM-NEXT: br label [[FOR_COND_OUTER:%.*]] |
| 40 | +; NEWPM: for.cond.outer: |
| 41 | +; NEWPM-NEXT: [[I_0_PH:%.*]] = phi i32 [ [[DEC:%.*]], [[IF_THEN:%.*]] ], [ 2, [[ENTRY:%.*]] ] |
| 42 | +; NEWPM-NEXT: [[CHANGED_0_OFF0_PH:%.*]] = phi i1 [ true, [[IF_THEN]] ], [ false, [[ENTRY]] ] |
| 43 | +; NEWPM-NEXT: br label [[FOR_COND:%.*]] |
| 44 | +; NEWPM: for.cond: |
| 45 | +; NEWPM-NEXT: [[I_0:%.*]] = phi i32 [ [[DEC]], [[FOR_BODY:%.*]] ], [ [[I_0_PH]], [[FOR_COND_OUTER]] ] |
| 46 | +; NEWPM-NEXT: [[DEC]] = add nsw i32 [[I_0]], -1 |
| 47 | +; NEWPM-NEXT: [[TOBOOL:%.*]] = icmp eq i32 [[I_0]], 0 |
| 48 | +; NEWPM-NEXT: br i1 [[TOBOOL]], label [[FOR_COND_CLEANUP:%.*]], label [[FOR_BODY]] |
| 49 | +; NEWPM: for.cond.cleanup: |
| 50 | +; NEWPM-NEXT: ret i1 [[CHANGED_0_OFF0_PH]] |
| 51 | +; NEWPM: for.body: |
| 52 | +; NEWPM-NEXT: [[IDXPROM:%.*]] = sext i32 [[DEC]] to i64 |
| 53 | +; NEWPM-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[C:%.*]], i64 [[IDXPROM]] |
| 54 | +; NEWPM-NEXT: [[TMP0:%.*]] = load i32, i32* [[ARRAYIDX]], align 4 |
| 55 | +; NEWPM-NEXT: [[CMP:%.*]] = icmp eq i32 [[OR]], [[TMP0]] |
| 56 | +; NEWPM-NEXT: br i1 [[CMP]], label [[FOR_COND]], label [[IF_THEN]] |
| 57 | +; NEWPM: if.then: |
| 58 | +; NEWPM-NEXT: store i32 [[OR]], i32* [[ARRAYIDX]], align 4 |
| 59 | +; NEWPM-NEXT: tail call void @foo() |
| 60 | +; NEWPM-NEXT: br label [[FOR_COND_OUTER]] |
34 | 61 | ;
|
35 | 62 | entry:
|
36 | 63 | br label %for.cond
|
@@ -64,43 +91,5 @@ if.end:
|
64 | 91 | br label %for.cond
|
65 | 92 | }
|
66 | 93 |
|
67 |
| -; PR34603 - https://bugs.llvm.org/show_bug.cgi?id=34603 |
68 |
| -; We should have a select of doubles, not a select of double pointers. |
69 |
| -; SimplifyCFG should not flatten this before early-cse has a chance to eliminate redundant ops. |
70 |
| - |
71 |
| -define double @max_of_loads(double* %x, double* %y, i64 %i) { |
72 |
| -; ALL-LABEL: @max_of_loads( |
73 |
| -; ALL-NEXT: entry: |
74 |
| -; ALL-NEXT: [[XI_PTR:%.*]] = getelementptr double, double* [[X:%.*]], i64 [[I:%.*]] |
75 |
| -; ALL-NEXT: [[YI_PTR:%.*]] = getelementptr double, double* [[Y:%.*]], i64 [[I]] |
76 |
| -; ALL-NEXT: [[XI:%.*]] = load double, double* [[XI_PTR]], align 8 |
77 |
| -; ALL-NEXT: [[YI:%.*]] = load double, double* [[YI_PTR]], align 8 |
78 |
| -; ALL-NEXT: [[CMP:%.*]] = fcmp ogt double [[XI]], [[YI]] |
79 |
| -; ALL-NEXT: [[Y_SINK:%.*]] = select i1 [[CMP]], double* [[X]], double* [[Y]] |
80 |
| -; ALL-NEXT: [[YI_PTR_AGAIN:%.*]] = getelementptr double, double* [[Y_SINK]], i64 [[I]] |
81 |
| -; ALL-NEXT: [[YI_AGAIN:%.*]] = load double, double* [[YI_PTR_AGAIN]], align 8 |
82 |
| -; ALL-NEXT: ret double [[YI_AGAIN]] |
83 |
| -; |
84 |
| -entry: |
85 |
| - %xi_ptr = getelementptr double, double* %x, i64 %i |
86 |
| - %yi_ptr = getelementptr double, double* %y, i64 %i |
87 |
| - %xi = load double, double* %xi_ptr |
88 |
| - %yi = load double, double* %yi_ptr |
89 |
| - %cmp = fcmp ogt double %xi, %yi |
90 |
| - br i1 %cmp, label %if, label %else |
91 |
| - |
92 |
| -if: |
93 |
| - %xi_ptr_again = getelementptr double, double* %x, i64 %i |
94 |
| - %xi_again = load double, double* %xi_ptr_again |
95 |
| - br label %end |
96 |
| - |
97 |
| -else: |
98 |
| - %yi_ptr_again = getelementptr double, double* %y, i64 %i |
99 |
| - %yi_again = load double, double* %yi_ptr_again |
100 |
| - br label %end |
101 |
| - |
102 |
| -end: |
103 |
| - %max = phi double [ %xi_again, %if ], [ %yi_again, %else ] |
104 |
| - ret double %max |
105 |
| -} |
| 94 | +declare void @foo() |
106 | 95 |
|
0 commit comments