Skip to content

Commit f1ab2f2

Browse files
committed
[InferAttrs] Handle f[min/max]imum_num like other libm functions
These behave like fmin and fmax.
1 parent adb7275 commit f1ab2f2

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

llvm/lib/Transforms/Utils/BuildLibCalls.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,6 +1356,12 @@ bool llvm::inferNonMandatoryLibFuncAttrs(Function &F,
13561356
case LibFunc_fmin:
13571357
case LibFunc_fminf:
13581358
case LibFunc_fminl:
1359+
case LibFunc_fmaximum_num:
1360+
case LibFunc_fmaximum_numf:
1361+
case LibFunc_fmaximum_numl:
1362+
case LibFunc_fminimum_num:
1363+
case LibFunc_fminimum_numf:
1364+
case LibFunc_fminimum_numl:
13591365
case LibFunc_labs:
13601366
case LibFunc_llabs:
13611367
case LibFunc_nearbyint:

llvm/test/Transforms/InferFunctionAttrs/annotate.ll

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,24 @@ declare float @fminf(float, float)
473473
; CHECK: declare x86_fp80 @fminl(x86_fp80, x86_fp80) [[MEMNONE_NOFREE_NOUNWIND_WILLRETURN:#[0-9]+]]
474474
declare x86_fp80 @fminl(x86_fp80, x86_fp80)
475475

476+
; CHECK: declare double @fmaximum_num(double, double) [[MEMNONE_NOFREE_NOUNWIND_WILLRETURN:#[0-9]+]]
477+
declare double @fmaximum_num(double, double)
478+
479+
; CHECK: declare float @fmaximum_numf(float, float) [[MEMNONE_NOFREE_NOUNWIND_WILLRETURN:#[0-9]+]]
480+
declare float @fmaximum_numf(float, float)
481+
482+
; CHECK: declare x86_fp80 @fmaximum_numl(x86_fp80, x86_fp80) [[MEMNONE_NOFREE_NOUNWIND_WILLRETURN:#[0-9]+]]
483+
declare x86_fp80 @fmaximum_numl(x86_fp80, x86_fp80)
484+
485+
; CHECK: declare double @fminimum_num(double, double) [[MEMNONE_NOFREE_NOUNWIND_WILLRETURN:#[0-9]+]]
486+
declare double @fminimum_num(double, double)
487+
488+
; CHECK: declare float @fminimum_numf(float, float) [[MEMNONE_NOFREE_NOUNWIND_WILLRETURN:#[0-9]+]]
489+
declare float @fminimum_numf(float, float)
490+
491+
; CHECK: declare x86_fp80 @fminimum_numl(x86_fp80, x86_fp80) [[MEMNONE_NOFREE_NOUNWIND_WILLRETURN:#[0-9]+]]
492+
declare x86_fp80 @fminimum_numl(x86_fp80, x86_fp80)
493+
476494
; CHECK: declare double @fmod(double, double) [[ERRNOMEMONLY_NOFREE_NOUNWIND_WILLRETURN:#[0-9]+]]
477495
declare double @fmod(double, double)
478496

0 commit comments

Comments
 (0)