@@ -135,3 +135,28 @@ define float @select_min_uge_2_use_cmp(float %a, float %b) {
135135 %sel = select nsz i1 %cmp , float %b , float %a
136136 ret float %sel
137137}
138+
139+ ; Make sure that we do not recognize the following pattern as a SPF
140+ ; unless the nsz flag is set on the select instruction.
141+
142+ define float @pr141017 (float %x ) {
143+ ; CHECK-LABEL: @pr141017(
144+ ; CHECK-NEXT: [[CMP:%.*]] = fcmp nsz olt float [[X:%.*]], 0.000000e+00
145+ ; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], float -0.000000e+00, float [[X]]
146+ ; CHECK-NEXT: ret float [[SEL]]
147+ ;
148+ %cmp = fcmp nsz olt float %x , 0 .0
149+ %sel = select i1 %cmp , float -0 .0 , float %x
150+ ret float %sel
151+ }
152+
153+ define float @pr141017_select_nsz (float %x ) {
154+ ; CHECK-LABEL: @pr141017_select_nsz(
155+ ; CHECK-NEXT: [[DOTINV:%.*]] = fcmp ole float [[X:%.*]], 0.000000e+00
156+ ; CHECK-NEXT: [[SEL1:%.*]] = select i1 [[DOTINV]], float -0.000000e+00, float [[X]]
157+ ; CHECK-NEXT: ret float [[SEL1]]
158+ ;
159+ %cmp = fcmp olt float %x , 0 .0
160+ %sel = select nsz i1 %cmp , float -0 .0 , float %x
161+ ret float %sel
162+ }
0 commit comments