Skip to content

fabs not marked readnone #2892

@nlewycky

Description

@nlewycky
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillallvm-toolsAll llvm tools that do not have corresponding tag

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions