public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/45176] New: restrict qualifier is not used in a manually unrolled loop
@ 2010-08-04 9:06 bmei at broadcom dot com
2010-08-04 9:20 ` [Bug c/45176] " rguenth at gcc dot gnu dot org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: bmei at broadcom dot com @ 2010-08-04 9:06 UTC (permalink / raw)
To: gcc-bugs
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/45176] restrict qualifier is not used in a manually unrolled loop
2010-08-04 9:06 [Bug c/45176] New: restrict qualifier is not used in a manually unrolled loop bmei at broadcom dot com
@ 2010-08-04 9:20 ` rguenth at gcc dot gnu dot org
2010-08-04 11:09 ` rguenth at gcc dot gnu dot org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-08-04 9:20 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from rguenth at gcc dot gnu dot org 2010-08-04 09:19 -------
I'll bootstrap & test that patch.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |rguenth at gcc dot gnu dot
|dot org |org
Status|UNCONFIRMED |ASSIGNED
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2010-08-04 09:19:37
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45176
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/45176] restrict qualifier is not used in a manually unrolled loop
2010-08-04 9:06 [Bug c/45176] New: restrict qualifier is not used in a manually unrolled loop bmei at broadcom dot com
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
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-08-04 11:09 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from rguenth at gcc dot gnu dot org 2010-08-04 11:09 -------
Subject: Bug 45176
Author: rguenth
Date: Wed Aug 4 11:08:54 2010
New Revision: 162862
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=162862
Log:
2010-08-04 Richard Guenther <rguenther@suse.de>
PR middle-end/45176
* expr.c (expand_expr_real_1): Also preserve TARGET_MEM_REF
points-to set for original MEM_REF.
Modified:
trunk/gcc/ChangeLog
trunk/gcc/expr.c
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45176
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/45176] restrict qualifier is not used in a manually unrolled loop
2010-08-04 9:06 [Bug c/45176] New: restrict qualifier is not used in a manually unrolled loop bmei at broadcom dot com
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
4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-08-04 11:10 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from rguenth at gcc dot gnu dot org 2010-08-04 11:09 -------
Fixed.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.6.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45176
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/45176] restrict qualifier is not used in a manually unrolled loop
2010-08-04 9:06 [Bug c/45176] New: restrict qualifier is not used in a manually unrolled loop bmei at broadcom dot com
` (2 preceding siblings ...)
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
4 siblings, 0 replies; 6+ messages in thread
From: siarhei dot siamashka at gmail dot com @ 2010-08-05 13:41 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from siarhei dot siamashka at gmail dot com 2010-08-05 13:40 -------
Looks like this missed optimization regression was introduced in gcc 4.5
Are any similar fixes possible in 4.5 branch?
--
siarhei dot siamashka at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |siarhei dot siamashka at
| |gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45176
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/45176] restrict qualifier is not used in a manually unrolled loop
2010-08-04 9:06 [Bug c/45176] New: restrict qualifier is not used in a manually unrolled loop bmei at broadcom dot com
` (3 preceding siblings ...)
2010-08-05 13:41 ` siarhei dot siamashka at gmail dot com
@ 2010-08-05 13:44 ` bmei at broadcom dot com
4 siblings, 0 replies; 6+ messages in thread
From: bmei at broadcom dot com @ 2010-08-05 13:44 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from bmei at broadcom dot com 2010-08-05 13:44 -------
I tried to apply the patches (this one alone is not enough) Richard suggested.
It becomes a chain of too many patches in the end. I am confident any more to
apply them to 4.5.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45176
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-08-05 13:44 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-04 9:06 [Bug c/45176] New: restrict qualifier is not used in a manually unrolled loop bmei at broadcom dot com
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
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).