[llvm-bugs] [Bug 37403] New: Missed optimization: fmax(a+n, b+n)
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu May 10 00:56:33 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=37403
Bug ID: 37403
Summary: Missed optimization: fmax(a+n, b+n)
Product: libraries
Version: 6.0
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: m-takahiro at jp.fujitsu.com
CC: llvm-bugs at lists.llvm.org
I compiled the following code by clang (tags/RELEASE_600/final 327104).
Option is '-Ofast -march=native'.
#include <math.h>
double foo(double a, double b, const double n) {
return fmax(a + n, b + n);
}
Generated IRs is as follows.
; Function Attrs: nounwind readnone uwtable
define double @foo(double, double, double) local_unnamed_addr #0 {
%4 = fadd fast double %2, %0
%5 = fadd fast double %2, %1
%6 = tail call fast double @llvm.maxnum.f64(double %4, double %5)
ret double %6
}
I think the above IRs can be simplified like the following IR when
'-ffast-math' is enabled.
; Function Attrs: nounwind readnone uwtable
define double @foo1(double, double, double) local_unnamed_addr #0 {
%3 = tail call fast double @llvm.maxnum.f64(double %0, double %1)
%4 = fadd fast double %2, %3
ret double %4
}
The same occurs about fmin.
#include <math.h>
double foo(double a, double b, const double n) {
return fmin(a + n, b + n);
}
-->
; Function Attrs: nounwind readnone uwtable
define double @foo(double, double, double) local_unnamed_addr #0 {
%4 = fadd fast double %2, %0
%5 = fadd fast double %2, %1
%6 = tail call fast double @llvm.minnum.f64(double %4, double %5)
ret double %6
}
--
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/20180510/fb823c63/attachment-0001.html>
More information about the llvm-bugs
mailing list