Weird behavior in LLVM regarding _finite math


It seems _finite math is gone for LLVM right now ( but there are still trace of it here:
$ cat a1.c
#include <math.h>
double log(double x){
return x;
$ cat a2.c
#include <math.h>
double mylog(double x){
return log(x);
Let compile both with -Ofast. We won’t see __log_finite in the a2.s but we will see the function name in a1.s is changed to __log_finite. Is it expected?

Hi Masoud:

This is because the math.h in your system still has FINITE_MATH_ONLY support.

-Ofast in clang will set macro __FINITE_MATH_ONLY__ to 1, so it will preprocess your code,
and go into finite math path, which will do the renaming using __asm.

extern double log (double) asm ("" “__log_finite”) attribute ((nothrow ));

This is expected. If you don’t want it, you can use -fno-finite-math-only…

Or you can use newer version of glibc (hence no finite path in math.h at all).


Jinsong Ji (纪金松), PhD.

XL/LLVM on Power Compiler Development

graycol.gifMasoud Ataei via llvm-dev —07/20/2020 02:09:38 PM—Hi, It seems _finite math is gone for LLVM right now (