llvm.org GIT mirror llvm / d68d614
[PassManager, SimplifyCFG] add test for PR34603 / D38566; NFC This is a recommit of r316908 which was reverted by r317444. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@318300 91177308-0d34-0410-b5e6-96231b3b80d8 Sanjay Patel 1 year, 10 months ago
1 changed file(s) with 40 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
6363
6464 declare void @foo()
6565
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.
69
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