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 tree-optimization/83352] New: Missed optimization in math expression: sqrt(sqrt(a)) == pow(a, 1/4)


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

            Bug ID: 83352
           Summary: Missed optimization in math expression: sqrt(sqrt(a))
                    == pow(a, 1/4)
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zamazan4ik at tut dot by
  Target Milestone: ---

gcc(trunk) with '--std=c++17 -O3 -march=native -ffast-math' flags for this
code:


#include <cmath>

double test(double a)
{
    return sqrt(sqrt(a));
}


generates this assembly:


test(double): # @test(double)
  vsqrtsd xmm0, xmm0, xmm0
  vsqrtsd xmm0, xmm0, xmm0
  ret


But there is formula: sqrt(sqrt(a)) == pow(a, 1/4). And it can be compiled in
faster way.

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