[llvm-bugs] [Bug 43428] New: Missed optimization: int range info isn't used

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Sep 24 05:22:24 PDT 2019


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

            Bug ID: 43428
           Summary: Missed optimization: int range info isn't used
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            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, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

For the following code:

unsigned sample(unsigned m ){
    if(m >= 10) return 42;
    return m / 10;
}

clang(trunk) with '-O3' generates this:

sample(unsigned int): # @sample(unsigned int)
  mov eax, 42
  cmp edi, 9
  ja .LBB0_2
  mov ecx, edi
  mov eax, 3435973837
  imul rax, rcx
  shr rax, 35
.LBB0_2:
  ret

but gcc(trunk) with 'O3' optimizes more and generates this:

sample(unsigned int):
  cmp edi, 10
  sbb eax, eax
  not eax
  and eax, 42
  ret

Godbolt playground: https://godbolt.org/z/Q-EaVW

-- 
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/20190924/210f8ed5/attachment.html>


More information about the llvm-bugs mailing list