[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


           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

$ 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 =
target triple = "i386-pc-linux-gnu"

define double @f(double* %x, double* %y) nounwind  {
        %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>
        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