Skip to content

Commit bae2401

Browse files
authored
[InstCombine] Add regression tests for f[min][max]imum_num libcalls (#170695)
Add tests corresponding to the existing fmin/fmax tests, as we'll later begin optimizing these into intrinsics.
1 parent d5551e1 commit bae2401

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

llvm/test/Transforms/InstCombine/float-shrink-compare.ll

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,40 @@ define i1 @test18(float %x, float %y, float %z) {
463463
ret i1 %5
464464
}
465465

466+
define i1 @test_fminimum_num(float %x, float %y, float %z) {
467+
; CHECK-LABEL: @test_fminimum_num(
468+
; CHECK-NEXT: [[TMP1:%.*]] = fpext float [[X:%.*]] to double
469+
; CHECK-NEXT: [[TMP2:%.*]] = fpext float [[Y:%.*]] to double
470+
; CHECK-NEXT: [[TMP3:%.*]] = call double @fminimum_num(double [[TMP1]], double [[TMP2]]) #[[ATTR3:[0-9]+]]
471+
; CHECK-NEXT: [[TMP4:%.*]] = fpext float [[Z:%.*]] to double
472+
; CHECK-NEXT: [[TMP5:%.*]] = fcmp oeq double [[TMP3]], [[TMP4]]
473+
; CHECK-NEXT: ret i1 [[TMP5]]
474+
;
475+
%1 = fpext float %x to double
476+
%2 = fpext float %y to double
477+
%3 = call double @fminimum_num(double %1, double %2) nounwind
478+
%4 = fpext float %z to double
479+
%5 = fcmp oeq double %3, %4
480+
ret i1 %5
481+
}
482+
483+
define i1 @test_fmaximum_num(float %x, float %y, float %z) {
484+
; CHECK-LABEL: @test_fmaximum_num(
485+
; CHECK-NEXT: [[TMP1:%.*]] = fpext float [[X:%.*]] to double
486+
; CHECK-NEXT: [[TMP2:%.*]] = fpext float [[Y:%.*]] to double
487+
; CHECK-NEXT: [[TMP3:%.*]] = call double @fmaximum_num(double [[TMP1]], double [[TMP2]]) #[[ATTR3]]
488+
; CHECK-NEXT: [[TMP4:%.*]] = fpext float [[Z:%.*]] to double
489+
; CHECK-NEXT: [[TMP5:%.*]] = fcmp oeq double [[TMP3]], [[TMP4]]
490+
; CHECK-NEXT: ret i1 [[TMP5]]
491+
;
492+
%1 = fpext float %x to double
493+
%2 = fpext float %y to double
494+
%3 = call double @fmaximum_num(double %1, double %2) nounwind
495+
%4 = fpext float %z to double
496+
%5 = fcmp oeq double %3, %4
497+
ret i1 %5
498+
}
499+
466500
define i1 @test19(float %x, float %y, float %z) {
467501
; CHECK-LABEL: @test19(
468502
; CHECK-NEXT: [[COPYSIGNF:%.*]] = call float @copysignf(float [[X:%.*]], float [[Y:%.*]]) #[[ATTR0:[0-9]+]]
@@ -518,6 +552,8 @@ declare double @roundeven(double) nounwind readnone
518552
declare double @trunc(double) nounwind readnone
519553
declare double @fmin(double, double) nounwind readnone
520554
declare double @fmax(double, double) nounwind readnone
555+
declare double @fminimum_num(double, double) nounwind readnone
556+
declare double @fmaximum_num(double, double) nounwind readnone
521557

522558
declare double @llvm.fabs.f64(double) nounwind readnone
523559
declare double @llvm.ceil.f64(double) nounwind readnone

0 commit comments

Comments
 (0)