Skip to content

Commit 7dc87cb

Browse files
authored
[InferAttrs] Handle f[min/max]imum_num like other libm functions (#170697)
These behave like fmin and fmax.
1 parent d4cc007 commit 7dc87cb

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
@@ -1353,6 +1353,12 @@ bool llvm::inferNonMandatoryLibFuncAttrs(Function &F,
13531353
case LibFunc_fmin:
13541354
case LibFunc_fminf:
13551355
case LibFunc_fminl:
1356+
case LibFunc_fmaximum_num:
1357+
case LibFunc_fmaximum_numf:
1358+
case LibFunc_fmaximum_numl:
1359+
case LibFunc_fminimum_num:
1360+
case LibFunc_fminimum_numf:
1361+
case LibFunc_fminimum_numl:
13561362
case LibFunc_labs:
13571363
case LibFunc_llabs:
13581364
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)