https://bugs.llvm.org/show_bug.cgi?id=34240

            Bug ID: 34240
           Summary: strange optimization for cos(cos(20)) with math.h but
                    not cmath
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangb...@nondot.org
          Reporter: xax...@gmail.com
                CC: dgre...@apple.com, llvm-bugs@lists.llvm.org

Recursive call with cos(cos(20)) in the body is reduced to no-op with cmath but
with math.h the generated code makes the recursive calls.

With only cos(20) both headers result in the generated code being a no-op.

#include <math.h>

void recurseTest(int level){

        for(int i =0; i < 15; i++){
                cos(cos(20));
                recurseTest(level +1);
        }
}

Strange behavior with math.h:
https://godbolt.org/g/y9gZW7

Desired behavior with cmath instead:
https://godbolt.org/g/rh9BMg

Desired behavior with math.h and only cos(20) not cos(cos(20))
https://godbolt.org/g/tn6EDg

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to