[llvm-bugs] [Bug 48317] New: __finite math calls generated prevents optimizations.
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Nov 27 05:53:31 PST 2020
https://bugs.llvm.org/show_bug.cgi?id=48317
Bug ID: 48317
Summary: __finite math calls generated prevents optimizations.
Product: tools
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: opt
Assignee: unassignedbugs at nondot.org
Reporter: venkataramanan.kumar.llvm at gmail.com
CC: llvm-bugs at lists.llvm.org
I am on Ubuntu 18 machine and it has finite math header <bits/math-finite.h>.
This header is included by the glibc 2.27. This header has this following
definition.
extern double log (double) asm ("" "log_finite") attribute__ ((nothrow ));
Consider the following test case
#include <math.h>
double mylog (double d) {
return log(d);
}
Recently clang started supporting asm labels.
Ref: https://reviews.llvm.org/D88712
Before this patch clang generates the below LLVM IR for -O2 -ffast-math
--Snip--
; Function Attrs: nounwind readnone uwtable
define dso_local double @mlog(double %d) local_unnamed_addr #0 {
entry:
%0 = tail call fast double @llvm.log.f64(double %d)
ret double %0
}
---Snip--
After this patch for -O2 -ffast-math, clang generates
--Snip--
; Function Attrs: nounwind readnone uwtable
define dso_local double @mlog(double %d) local_unnamed_addr #0 {
entry:
%call = tail call fast double @__log_finite(double %d) #2
ret double %call
}
--Snip--
Note on latest Ubuntu 20.04.1 LTS with Glibc 2.31 <bits/math-finite.h> header
is not present. It is removed by glibc. so there I see the @llvm.log.f64
intrinsic calls.
So on machines with lesser glibc versions where the header file is present this
will be a problem as it generates finite calls now.
Note the LLVM "opt" does optimizations like vectorization only on the
intrinsic, but fails to do so in the presence of calls to @__log_finite.
Example https://llvm.godbolt.org/z/765We8
Older glibc versions are still supported OS distros. We are seeing performance
issues due to this finite calls.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20201127/5ba6ad24/attachment.html>
More information about the llvm-bugs
mailing list