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

            Bug ID: 35711
           Summary: std::gcd and std::lcm doesn't precalculate in
                    compile-time
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: LLVM Codegen
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]

clang (trunk) with '-O3 -std=c++17' for this code:

#include <numeric>

unsigned test()
{
    return std::gcd(2,4);
}


generates this:

test(): # @test()
  mov edx, 4
  mov eax, 2
.LBB0_1: # =>This Inner Loop Header: Depth=1
  mov ecx, edx
  cdq
  idiv ecx
  mov eax, ecx
  test edx, edx
  jne .LBB0_1
  mov eax, ecx
  neg eax
  cmovl eax, ecx
  ret


gcc (trunk) with '-O3 -std=c++17':

test():
  mov eax, 2
  ret



Similar issue fot std::lcm (GCC also calculate it in compile-time).

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

Reply via email to