public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "bmei at broadcom dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/45176] New: restrict qualifier is not used in a manually unrolled loop Date: Wed, 04 Aug 2010 09:06:00 -0000 [thread overview] Message-ID: <bug-45176-15361@http.gcc.gnu.org/bugzilla/> (raw) void foo (int * restrict a, int * restrict b, int * restrict c) { int i; for(i = 0; i < 100; i+=4) { a[i] = b[i] * c[i]; a[i+1] = b[i+1] * c[i+1]; a[i+2] = b[i+2] * c[i+2]; a[i+3] = b[i+3] * c[i+3]; } } Trunk x86-64 compiler (162821) produces code that later load instructions are not scheduled before the previous store instructions as expected. Clearly, restrict qualifier is not used here. ~/work/install-x86/bin/gcc tst3.c -O2 -S -std=c99 -da -fschedule-insns -frename-registers .L2: movl (%rdx,%rax), %r10d imull (%rsi,%rax), %r10d movl %r10d, (%rdi,%rax) movl 4(%rdx,%rax), %r9d imull 4(%rsi,%rax), %r9d movl %r9d, 4(%rdi,%rax) movl 8(%rdx,%rax), %r8d imull 8(%rsi,%rax), %r8d movl %r8d, 8(%rdi,%rax) movl 12(%rdx,%rax), %ecx imull 12(%rsi,%rax), %ecx movl %ecx, 12(%rdi,%rax) addq $16, %rax cmpq $400, %rax Richard has a patch and it seems to work for this example. Index: expr.c =================================================================== --- expr.c (revision 162841) +++ expr.c (working copy) @@ -8665,7 +8665,7 @@ expand_expr_real_1 (tree exp, rtx target set_mem_addr_space (temp, as); base = get_base_address (TMR_ORIGINAL (exp)); if (base - && INDIRECT_REF_P (base) + && (INDIRECT_REF_P (base) || TREE_CODE (base) == MEM_REF) && TMR_BASE (exp) && TREE_CODE (TMR_BASE (exp)) == SSA_NAME && POINTER_TYPE_P (TREE_TYPE (TMR_BASE (exp)))) The code generated: .L2: movl (%rdx,%rax), %r10d movl 4(%rdx,%rax), %r9d imull (%rsi,%rax), %r10d imull 4(%rsi,%rax), %r9d movl 8(%rdx,%rax), %r8d movl 12(%rdx,%rax), %ecx imull 8(%rsi,%rax), %r8d imull 12(%rsi,%rax), %ecx movl %r10d, (%rdi,%rax) movl %r9d, 4(%rdi,%rax) movl %r8d, 8(%rdi,%rax) movl %ecx, 12(%rdi,%rax) addq $16, %rax cmpq $400, %rax jne .L2 -- Summary: restrict qualifier is not used in a manually unrolled loop Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: bmei at broadcom dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45176
next reply other threads:[~2010-08-04 9:06 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2010-08-04 9:06 bmei at broadcom dot com [this message] 2010-08-04 9:20 ` [Bug c/45176] " rguenth at gcc dot gnu dot org 2010-08-04 11:09 ` rguenth at gcc dot gnu dot org 2010-08-04 11:10 ` rguenth at gcc dot gnu dot org 2010-08-05 13:41 ` siarhei dot siamashka at gmail dot com 2010-08-05 13:44 ` bmei at broadcom dot com
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=bug-45176-15361@http.gcc.gnu.org/bugzilla/ \ --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).