https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94892

Harald van Dijk <harald at gigawatt dot nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |harald at gigawatt dot nl

--- Comment #3 from Harald van Dijk <harald at gigawatt dot nl> ---
Changing the test slightly to

  inline int sign(int x)
  {
    return (x >> 31) | ((unsigned)-x >> 31);
  }

  void f1(void);
  void f2(void);
  void f(int x)
  {
    if (sign(x) > -1)
      f1();
    else
      f2();
  }

shows at -O3 with LLVM:

  f:
    test    edi, edi
    js      .LBB0_2
    jmp     f1
  .LBB0_2:
    jmp     f2

whereas GCC produces:

  f:
    mov     eax, edi
    sar     edi, 31
    neg     eax
    shr     eax, 31
    or      edi, eax
    cmp     edi, -1
    je      .L2
    jmp     f1
  .L2:
    jmp     f2

In that example, LLVM is doing much better.

Reply via email to