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: unassignedclangb...@nondot.org
          Reporter: zamazan...@tut.by
                CC: llvm-bugs@lists.llvm.org, neeil...@live.com,
                    richard-l...@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to