[Bug tree-optimization/94913] Failure to optimize not+cmp into overflow check

ubizjak at gmail dot com gcc-bugzilla@gcc.gnu.org
Tue May 5 20:03:44 GMT 2020


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

--- Comment #2 from Uroš Bizjak <ubizjak at gmail dot com> ---
Created attachment 48458
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48458&action=edit
Prototype patch

Prototype patch for missed optimization, described in Comment #0.

Following testcase:

--cut here--
int
foo (unsigned int x, unsigned int y)
{
  return ~x < y;
}

void f1 (void);
void f2 (void);

void
bar (unsigned int x, unsigned int y)
{
  if (~x < y)
    f1 ();
  else
    f2 ();
}
--cut here--

compiles (-O2) to:

foo:
        xorl    %eax, %eax
        addl    %esi, %edi
        setc    %al
        ret

bar:
        addl    %esi, %edi
        jnc     .L4
        jmp     f1
.L4:
        jmp     f2


More information about the Gcc-bugs mailing list