-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Description
| Bugzilla Link | 2520 |
| Resolution | FIXED |
| Resolved on | Jul 08, 2008 05:13 |
| Version | trunk |
| OS | Linux |
Extended Description
According to fabs(3), none of fabs fabsf or fabsl can have any errors. As such, they should be marked readnone since all they ever do is return their own input.
$ cat fabs.c
#include <math.h>
double f(double *x, double *y) { return fabs(*x + *y); }
$ llvm-gcc -O2 fabs.c -S -o - -emit-llvm
; ModuleID = 'fabs.c'
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32"
target triple = "i386-pc-linux-gnu"
define double @f(double* %x, double* %y) nounwind {
entry:
%tmp2 = load double* %x, align 8 ; [#uses=1]
%tmp4 = load double* %y, align 8 ; [#uses=1]
%tmp5 = add double %tmp2, %tmp4 ; [#uses=1]
%tmp6 = tail call double @fabs( double %tmp5 ) ; [#uses=1]
ret double %tmp6
}
declare double @fabs(double)
This stops some optimizations from working (GVN in particular) because it doesn't know that fabs() won't be writing to one of the double* arguments.