This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/77453] New: No builtin version of cbrtf


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77453

            Bug ID: 77453
           Summary: No builtin version of cbrtf
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: matthieu.schaller at durham dot ac.uk
  Target Milestone: ---

More of a feature request than a bug. 

System: Any Linux platform
GCC version : Any

I have a piece of software that relies heavily on the math cube root function
'cbrtf()'. According to the GCC documentation this function can be replaced by
builtins. However, this does not seem to be the case.

Compiling with `-O3 -std=gnu11 -ffast-math`, the following snippet

float pow_gamma(float x) {

  const float cbrt = cbrtf(x); /* x^(1/3) */
  return cbrt * cbrt  * x;      /* x^(5/3) */
}  

leads to the following assembly:

pow_gamma(float):
        subq    $24, %rsp
        movss   %xmm0, 12(%rsp)
        call    cbrtf
        mulss   %xmm0, %xmm0
        movss   12(%rsp), %xmm1
        addq    $24, %rsp
        mulss   %xmm1, %xmm0
        ret

with a clear call to a function rather than a builtin. 

Note that when repeating the exercise with a sqrt rather than cbrt, GCC
replaces the call to the function by the sqrt assembly instruction, as
expected.

Could a builtin version of `cbrtf` be added ?

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]