llvm.org GIT mirror llvm / 963ec73
[PassManager, SimplifyCFG] add test for PR34603 / D38566; NFC Sinking common insts and converting to select early can inhibit better folds in other passes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316908 91177308-0d34-0410-b5e6-96231b3b80d8 Sanjay Patel 1 year, 10 months ago
1 changed file(s) with 41 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
0 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
11 ; RUN: opt -O1 -S < %s | FileCheck %s --check-prefix=ALL --check-prefix=OLDPM
22 ; RUN: opt -passes='default' -S < %s | FileCheck %s --check-prefix=ALL --check-prefix=NEWPM
3
4 declare void @foo()
35
46 ; Don't simplify unconditional branches from empty blocks in simplifyCFG
57 ; until late in the pipeline because it can destroy canonical loop structure.
6163 br label %for.cond
6264 }
6365
64 declare void @foo()
66 ; PR34603 - https://bugs.llvm.org/show_bug.cgi?id=34603
67 ; We should have a select of doubles, not a select of double pointers.
68 ; SimplifyCFG should not flatten this before early-cse has a chance to eliminate redundant ops.
6569
70 define double @max_of_loads(double* %x, double* %y, i64 %i) {
71 ; ALL-LABEL: @max_of_loads(
72 ; ALL-NEXT: entry:
73 ; ALL-NEXT: [[XI_PTR:%.*]] = getelementptr double, double* [[X:%.*]], i64 [[I:%.*]]
74 ; ALL-NEXT: [[YI_PTR:%.*]] = getelementptr double, double* [[Y:%.*]], i64 [[I]]
75 ; ALL-NEXT: [[XI:%.*]] = load double, double* [[XI_PTR]], align 8
76 ; ALL-NEXT: [[YI:%.*]] = load double, double* [[YI_PTR]], align 8
77 ; ALL-NEXT: [[CMP:%.*]] = fcmp ogt double [[XI]], [[YI]]
78 ; ALL-NEXT: [[Y_SINK:%.*]] = select i1 [[CMP]], double* [[X]], double* [[Y]]
79 ; ALL-NEXT: [[YI_PTR_AGAIN:%.*]] = getelementptr double, double* [[Y_SINK]], i64 [[I]]
80 ; ALL-NEXT: [[YI_AGAIN:%.*]] = load double, double* [[YI_PTR_AGAIN]], align 8
81 ; ALL-NEXT: ret double [[YI_AGAIN]]
82 ;
83 entry:
84 %xi_ptr = getelementptr double, double* %x, i64 %i
85 %yi_ptr = getelementptr double, double* %y, i64 %i
86 %xi = load double, double* %xi_ptr
87 %yi = load double, double* %yi_ptr
88 %cmp = fcmp ogt double %xi, %yi
89 br i1 %cmp, label %if, label %else
90
91 if:
92 %xi_ptr_again = getelementptr double, double* %x, i64 %i
93 %xi_again = load double, double* %xi_ptr_again
94 br label %end
95
96 else:
97 %yi_ptr_again = getelementptr double, double* %y, i64 %i
98 %yi_again = load double, double* %yi_ptr_again
99 br label %end
100
101 end:
102 %max = phi double [ %xi_again, %if ], [ %yi_again, %else ]
103 ret double %max
104 }
105