[LLVMbugs] [Bug 2520] New: fabs not marked readnone

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Sun Jul 6 17:07:09 PDT 2008


http://llvm.org/bugs/show_bug.cgi?id=2520

           Summary: fabs not marked readnone
           Product: tools
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: llvm-gcc
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: nicholas at mxc.ca
                CC: llvmbugs at cs.uiuc.edu


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                ; <double> [#uses=1]
        %tmp4 = load double* %y, align 8                ; <double> [#uses=1]
        %tmp5 = add double %tmp2, %tmp4         ; <double> [#uses=1]
        %tmp6 = tail call double @fabs( double %tmp5 )          ; <double>
[#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.


-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list