[llvm-bugs] [Bug 35711] New: std::gcd and std::lcm doesn't precalculate in compile-time

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Dec 20 13:30:44 PST 2017


            Bug ID: 35711
           Summary: std::gcd and std::lcm doesn't precalculate in
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: zamazan4ik at tut.by
                CC: llvm-bugs at lists.llvm.org

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
  idiv ecx
  mov eax, ecx
  test edx, edx
  jne .LBB0_1
  mov eax, ecx
  neg eax
  cmovl eax, ecx

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

  mov eax, 2

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20171220/f41a40cd/attachment.html>

More information about the llvm-bugs mailing list