public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "hjl at lucon dot org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/17387] New: Redundant instructions in loop optimization Date: Thu, 09 Sep 2004 23:54:00 -0000 [thread overview] Message-ID: <20040909235415.17387.hjl@lucon.org> (raw) For this code: extern unsigned int S[]; extern unsigned int state[]; unsigned int foo () { register unsigned int t; register int j; j=0; t=0; for (j=0; j<16; j+=4) { t= state[j+ 0]^=S[t]; t= state[j+ 1]^=S[t]; t= state[j+ 2]^=S[t]; t= state[j+ 3]^=S[t]; } t=(t)&0xff; return t; } With -O3, gcc generates: foo: .LFB2: xorl %esi, %esi xorl %ecx, %ecx .p2align 4,,7 .L2: movslq %esi,%rdx mov %ecx, %eax movl S(,%rax,4), %eax xorl state(,%rdx,4), %eax movl %eax, state(,%rdx,4) leal 1(%rsi), %edx mov %eax, %eax <====== Why? movl S(,%rax,4), %eax movslq %edx,%rdx xorl state(,%rdx,4), %eax movl %eax, state(,%rdx,4) leal 2(%rsi), %edx mov %eax, %eax <====== Why? movl S(,%rax,4), %eax movslq %edx,%rdx xorl state(,%rdx,4), %eax movl %eax, state(,%rdx,4) leal 3(%rsi), %edx mov %eax, %eax <====== Why? movl S(,%rax,4), %ecx leal 4(%rsi), %eax movslq %edx,%rdx xorl state(,%rdx,4), %ecx cmpl $16, %eax movl %eax, %esi movl %ecx, state(,%rdx,4) jne .L2 movzbl %cl,%eax ret With -O3, gcc 3.4.3 gets foo: .LFB2: xorl %edi, %edi xorl %ecx, %ecx movl $state, %esi .p2align 4,,7 .L5: movslq %ecx,%rdx mov %edi, %eax addl $4, %ecx movl S(,%rax,4), %r11d xorl state(,%rdx,4), %r11d mov %r11d, %r10d <====== Why? movl %r11d, state(,%rdx,4) movl S(,%r10,4), %r9d xorl state+4(,%rdx,4), %r9d mov %r9d, %r8d <====== Why? movl %r9d, 4(%rsi,%rdx,4) movl S(,%r8,4), %edi xorl state+8(,%rdx,4), %edi mov %edi, %eax <====== Why? movl %edi, 8(%rsi,%rdx,4) movl S(,%rax,4), %eax xorl state+12(,%rdx,4), %eax cmpl $15, %ecx movl %eax, 12(%rsi,%rdx,4) movl %eax, %edi jle .L5 andl $255, %eax ret -- Summary: Redundant instructions in loop optimization Product: gcc Version: 4.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: hjl at lucon dot org CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: x86_64-unknown-linux-gnu GCC host triplet: x86_64-unknown-linux-gnu GCC target triplet: x86_64-unknown-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17387
next reply other threads:[~2004-09-09 23:54 UTC|newest] Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top 2004-09-09 23:54 hjl at lucon dot org [this message] 2004-09-10 0:36 ` [Bug rtl-optimization/17387] " pinskia at gcc dot gnu dot org 2004-09-10 2:50 ` law at gcc dot gnu dot org 2004-09-10 8:05 ` pinskia at gcc dot gnu dot org 2004-09-10 9:53 ` hubicka at gcc dot gnu dot org 2004-09-10 23:22 ` pinskia at gcc dot gnu dot org 2004-09-11 19:55 ` rakdver at gcc dot gnu dot org 2004-11-27 20:49 ` pinskia at gcc dot gnu dot org 2005-01-23 13:36 ` steven at gcc dot gnu dot org 2005-01-24 18:17 ` hjl at lucon dot org 2005-01-24 18:53 ` pinskia at gcc dot gnu dot org 2005-01-27 1:27 ` steven at gcc dot gnu dot org 2005-01-27 1:36 ` steven at gcc dot gnu dot org 2005-01-27 1:43 ` steven at gcc dot gnu dot org 2005-01-27 4:03 ` hjl at lucon dot org 2005-01-27 6:05 ` rth at gcc dot gnu dot org 2005-01-27 7:14 ` stevenb at suse dot de 2005-01-27 10:14 ` steven at gcc dot gnu dot org 2005-01-27 10:27 ` steven at gcc dot gnu dot org 2005-01-27 10:28 ` steven at gcc dot gnu dot org 2005-01-27 13:36 ` pinskia at gcc dot gnu dot org 2005-09-29 3:44 ` pinskia at gcc dot gnu dot org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20040909235415.17387.hjl@lucon.org \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).