public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/39874]  New: [4.4 regression] missing DCE
@ 2009-04-23 19:13 alexvod at google dot com
  2009-04-23 19:18 ` [Bug tree-optimization/39874] [4.4 regression] missing VRP (submission) pinskia at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: alexvod at google dot com @ 2009-04-23 19:13 UTC (permalink / raw)
  To: gcc-bugs

The following code:
void func();
void test(char *signature)
{
  char ch = signature[0];
  if (ch == 15 || ch == 3)
  {
    if (ch == 15) func();
  }
}
is compiled in suboptimal way by gcc 4.4. Check for ch==3 can be completely
eliminated since func is only called if ch==15. gcc 4.3 is able to properly
infer this and eliminate the unneeded check, but gcc 4.4 fails to do this.

Althouth, found originally on ARM, this bug also reproduces on x86 as well.

gcc 4.3.1 (with -m32 -O2):
test:
      pushl   %ebp
      movl    %esp, %ebp
      movl    8(%ebp), %eax
      movzbl  (%eax), %eax
      cmpb    $15, %al           // %al compared only with 15
      jne     .L8
      popl    %ebp
      jmp     func
.L8:
      popl    %ebp
      ret

gcc 4.4.0:
test:
      pushl   %ebp
      movl    %esp, %ebp
      subl    $8, %esp
      movl    8(%ebp), %eax
      movzbl  (%eax), %eax
      cmpb    $15, %al
      sete    %dl
      cmpb    $3, %al   // compiler was not able to optimize ch==3
      je      .L4
      testb   %dl, %dl
      jne     .L8
.L4:
      leave
      ret
      .p2align 4,,7
      .p2align 3
.L8:
      leave
      .p2align 4,,8
      .p2align 3
      jmp     func

Bisection shows that it was introduced by
http://gcc.gnu.org/viewcvs?view=rev&revision=140288


-- 
           Summary: [4.4 regression] missing DCE
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: alexvod at google dot com
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86-unknown-linux-gnu, arm-eabi


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


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

end of thread, other threads:[~2010-06-08 18:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-23 19:13 [Bug tree-optimization/39874] New: [4.4 regression] missing DCE alexvod at google dot com
2009-04-23 19:18 ` [Bug tree-optimization/39874] [4.4 regression] missing VRP (submission) pinskia at gcc dot gnu dot org
2009-04-24  9:24 ` rguenth at gcc dot gnu dot org
2010-05-24 13:08 ` sandra at codesourcery dot com
2010-06-01  2:23 ` sandra at codesourcery dot com
2010-06-08 18:16 ` sandra at gcc dot gnu dot 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).