This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug middle-end/28685] New: Multiple comparisons are not simplified


These two testcases should produce equivalent code:

int test(int a, int b)
{
  int lt = a < b;
  int eq = a == b;

  return (lt || eq);
}

int test_(int a, int b)
{
  return (a < b || a == b);
}

However, the optimized tree code is:

;; Function test (test)

Analyzing Edge Insertions.
test (a, b)
{
<bb 2>:
  return (a == b | a < b) != 0;

}

;; Function test_ (test_)

Analyzing Edge Insertions.
test_ (a, b)
{
<bb 2>:
  return a <= b;

}

And the resultinh x86_64 asm is unoptimal for test() function:

test:
        cmpl    %esi, %edi
        sete    %dl
        cmpl    %esi, %edi
        setl    %al
        orl     %edx, %eax
        movzbl  %al, %eax
        ret

test_:
        xorl    %eax, %eax
        cmpl    %esi, %edi
        setle   %al
        ret


-- 
           Summary: Multiple comparisons are not simplified
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: uros at kss-loka dot si
 GCC build triplet: x86_64-pc-linux-gnu
  GCC host triplet: x86_64-pc-linux-gnu
GCC target triplet: x86_64-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28685


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]