public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/28940]  New: Overzealous CSE with static array access
@ 2006-09-02 21:14 lmakhlis at bmc dot com
  2006-09-02 21:29 ` [Bug rtl-optimization/28940] [4.1/4.2 Regression] address selection does not work correctly pinskia at gcc dot gnu dot org
                   ` (18 more replies)
  0 siblings, 19 replies; 20+ messages in thread
From: lmakhlis at bmc dot com @ 2006-09-02 21:14 UTC (permalink / raw)
  To: gcc-bugs

char a[10], b[10];

int f1(int i)
{
        return a[i+1] + b[i+1];
}

With -O1 and higher, gcc performs CSE on i+1:

        addl    $1, %edi
        movslq  %edi,%rdi
        movsbl  a(%rdi),%eax
        movsbl  b(%rdi),%edx
        addl    %edx, %eax
        ret

This doesn't happen with the equivalent
        return (&a[0])[i+1] + (&b[0])[i+1];
or
        return *(a + i + 1) + *(b + i + 1);
which both compile to
        movslq  %edi,%rdi
        movsbl  a+1(%rdi),%eax
        movsbl  b+1(%rdi),%edx
        addl    %edx, %eax
        ret


-- 
           Summary: Overzealous CSE with static array access
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: lmakhlis at bmc dot com
 GCC build triplet: x86_64-redhat-linux
  GCC host triplet: x86_64-redhat-linux
GCC target triplet: x86_64-redhat-linux


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


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

end of thread, other threads:[~2007-11-03  7:54 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-09-02 21:14 [Bug tree-optimization/28940] New: Overzealous CSE with static array access lmakhlis at bmc dot com
2006-09-02 21:29 ` [Bug rtl-optimization/28940] [4.1/4.2 Regression] address selection does not work correctly pinskia at gcc dot gnu dot org
2006-09-07  1:16 ` mmitchel at gcc dot gnu dot org
2006-09-07  8:11 ` bonzini at gnu dot org
2006-09-07  8:15 ` bonzini at gnu dot org
2006-09-09  5:48 ` [Bug rtl-optimization/28940] [4.0/4.1/4.2 " pinskia at gcc dot gnu dot org
2006-09-09 13:02 ` bonzini at gnu dot org
2006-09-09 13:03 ` bonzini at gnu dot org
2006-10-11 12:23 ` [Bug c/28940] " rguenth at gcc dot gnu dot org
2006-10-11 12:30 ` rguenth at gcc dot gnu dot org
2006-10-11 12:47 ` bonzini at gnu dot org
2006-10-11 12:53 ` rguenth at gcc dot gnu dot org
2006-10-11 13:05 ` paolo dot bonzini at lu dot unisi dot ch
2007-01-15 20:21 ` [Bug rtl-optimization/28940] " pinskia at gcc dot gnu dot org
2007-02-14  9:19 ` mmitchel at gcc dot gnu dot org
2007-07-05 10:37 ` bonzini at gnu dot org
2007-07-05 10:43 ` ebotcazou at gcc dot gnu dot org
2007-07-05 10:46 ` paolo dot bonzini at lu dot unisi dot ch
2007-11-03  7:53 ` ebotcazou at gcc dot gnu dot org
2007-11-03  7:54 ` ebotcazou 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).