Skip to content

Commit 7d7d89d

Browse files
committed
[InstCombine] Add pre-commit tests. NFC.
1 parent f5805d2 commit 7d7d89d

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

llvm/test/Transforms/InstCombine/unordered-fcmp-select.ll

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)