Skip to content

Commit 9b89df7

Browse files
committed
GVN: add test for denormals
1 parent 6377672 commit 9b89df7

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

llvm/test/Transforms/GVN/edge.ll

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,34 @@ return:
224224
ret double %retval
225225
}
226226

227+
; Denormals may be flushed to zero in some cases by the backend.
228+
; Hence, treat denormals as 0.
229+
define float @fcmp_oeq_denormal(float %x, float %y) {
230+
; CHECK-LABEL: define float @fcmp_oeq_denormal(
231+
; CHECK-SAME: float [[X:%.*]], float [[Y:%.*]]) {
232+
; CHECK-NEXT: [[ENTRY:.*]]:
233+
; CHECK-NEXT: [[CMP:%.*]] = fcmp oeq float [[Y]], 0x3800000000000000
234+
; CHECK-NEXT: br i1 [[CMP]], label %[[IF:.*]], label %[[RETURN:.*]]
235+
; CHECK: [[IF]]:
236+
; CHECK-NEXT: [[DIV:%.*]] = fdiv float [[X]], [[Y]]
237+
; CHECK-NEXT: br label %[[RETURN]]
238+
; CHECK: [[RETURN]]:
239+
; CHECK-NEXT: [[RETVAL:%.*]] = phi float [ [[DIV]], %[[IF]] ], [ [[X]], %[[ENTRY]] ]
240+
; CHECK-NEXT: ret float [[RETVAL]]
241+
;
242+
entry:
243+
%cmp = fcmp oeq float %y, 0x3800000000000000
244+
br i1 %cmp, label %if, label %return
245+
246+
if:
247+
%div = fdiv float %x, %y
248+
br label %return
249+
250+
return:
251+
%retval = phi float [ %div, %if ], [ %x, %entry ]
252+
ret float %retval
253+
}
254+
227255
define double @fcmp_une_zero(double %x, double %y) {
228256
; CHECK-LABEL: define double @fcmp_une_zero(
229257
; CHECK-SAME: double [[X:%.*]], double [[Y:%.*]]) {
@@ -251,7 +279,7 @@ return:
251279
}
252280

253281
; We also cannot propagate a value if it's not a constant.
254-
; This is because the value could be 0.0 or -0.0.
282+
; This is because the value could be 0.0, -0.0, or a denormal.
255283

256284
define double @fcmp_oeq_maybe_zero(double %x, double %y, double %z1, double %z2) {
257285
; CHECK-LABEL: define double @fcmp_oeq_maybe_zero(

0 commit comments

Comments
 (0)