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

            Bug ID: 48768
           Summary: Failure to optimize using flags from blsi
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]

int f(unsigned long x)
{
    return 0 >= (int)(-x & x);
}

With -O3 -mbmi, GCC emits this:

f(unsigned long):
  xor eax, eax
  blsi edi, edi
  setle al
  ret

LLVM emits this:

f(unsigned long): # @f(unsigned long)
  blsi ecx, edi
  xor eax, eax
  test ecx, ecx
  setle al
  ret

The usage of the `test` instruction is useless as the flags from `blsi` can
directly be used.

See also Godbolt comparison here : https://godbolt.org/z/dqb18e

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

Reply via email to