[llvm-bugs] [Bug 47237] New: Failure to optimize simple selection properly, somehow the code degenerates
    via llvm-bugs 
    llvm-bugs at lists.llvm.org
       
    Wed Aug 19 08:34:49 PDT 2020
    
    
  
https://bugs.llvm.org/show_bug.cgi?id=47237
            Bug ID: 47237
           Summary: Failure to optimize simple selection properly, somehow
                    the code degenerates
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: gabravier at gmail.com
                CC: llvm-bugs at lists.llvm.org
int f(int x, int y)
{
    return (x & y) == 0 ? x & ~y : x;
}
GCC outputs this :
f(int, int):
  andn edx, esi, edi
  mov eax, edi
  test edi, esi
  cmove eax, edx
  ret
And LLVM outputs this :
f(int, int): # @f(int, int)
  mov ecx, esi
  and ecx, edi
  not esi
  xor eax, eax
  cmp ecx, 1
  sbb eax, eax
  not eax
  or eax, esi
  and eax, edi
  ret
Most likely some sort of transformation in LLVM makes this code completely
degenerate into the result given here.
-- 
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/20200819/68536e20/attachment.html>
    
    
More information about the llvm-bugs
mailing list