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

            Bug ID: 77881
           Summary: [5/6/7 Regression] Non-optimal signed comparison on
                    x86_64 since r146817
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jakub at gcc dot gnu.org
  Target Milestone: ---

int
foo (long long int a, int b)
{
  if (a >= 0 || b)
    baz ();
}

int
bar (long long int a, int b)
{
  if (a < 0 || b)
    baz ();
}

on x86_64-linux with -O2 is compiled into following starting with r146817:
        testq   %rdi, %rdi
        jns     .L4
        testl   %esi, %esi
        jne     .L4
for foo, which looks reasonable, and
        shrq    $63, %rdi
        testb   %dil, %dil
        jne     .L9
        testl   %esi, %esi
        jne     .L9
in bar, where I'd expect and we used to emit in the past
        testq   %rdi, %rdi
        js      .L9
        testl   %esi, %esi
        jne     .L9
or something similar.  I wonder if we want a combine pattern that would
transform right shift by precision - 1 followed by comparison of the result
against 0 if the result of the right shift is dead into just signed comparison.

Reply via email to