public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/95784] New: Failure to optimize usage of __builtin_add_overflow with return statement properly
@ 2020-06-20 10:13 gabravier at gmail dot com
  2020-06-20 12:09 ` [Bug target/95784] " pinskia at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: gabravier at gmail dot com @ 2020-06-20 10:13 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 95784
           Summary: Failure to optimize usage of __builtin_add_overflow
                    with return statement properly
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gabravier at gmail dot com
  Target Milestone: ---

int f(uint8_t operand, int8_t *result)
{
    if (__builtin_add_overflow(operand, 0, result))
    {
        *result = 0;
        return 10213;
    }
    return 0;
}

With -O3, LLVM outputs this :

f(unsigned char, signed char*): # @f(unsigned char, signed char*)
  movsx eax, dil
  xor ecx, ecx
  cmp edi, eax
  cmovne edi, ecx
  mov byte ptr [rsi], dil
  mov eax, 10213
  cmove eax, ecx
  ret

GCC outputs this :

f(unsigned char, signed char*):
  movzx eax, dil
  movsx di, dil
  cmp ax, di
  setne dl
  mov r8d, edx
  sal r8d, 31
  sar r8d, 31
  and r8d, 10213
  test dl, dl
  mov edx, 0
  cmovne eax, edx
  mov BYTE PTR [rsi], al
  mov eax, r8d
  ret

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-08-03  3:44 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-20 10:13 [Bug tree-optimization/95784] New: Failure to optimize usage of __builtin_add_overflow with return statement properly gabravier at gmail dot com
2020-06-20 12:09 ` [Bug target/95784] " pinskia at gcc dot gnu.org
2020-06-20 14:01 ` gabravier at gmail dot com
2020-06-20 14:02 ` gabravier at gmail dot com
2020-06-20 14:25 ` gabravier at gmail dot com
2020-06-20 14:27 ` gabravier at gmail dot com
2020-06-20 14:33 ` gabravier at gmail dot com
2020-06-20 15:51 ` jakub at gcc dot gnu.org
2020-06-20 19:05 ` gabravier at gmail dot com
2020-06-22  8:05 ` rguenth at gcc dot gnu.org
2021-08-03  3:44 ` [Bug rtl-optimization/95784] " pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).