public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/22497] New: A register is wasted in simple vectorised loops
@ 2005-07-15 10:09 uros at kss-loka dot si
2005-07-15 22:19 ` [Bug target/22497] " pinskia at gcc dot gnu dot org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: uros at kss-loka dot si @ 2005-07-15 10:09 UTC (permalink / raw)
To: gcc-bugs
Hello!
Consider this simple testcase:
#define N 16
short ia[N];
short ic[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45};
short ib[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45};
int main ()
{
int i;
for (i = 0; i < N; i++)
ia[i] = ib[i] + ic[i];
return 0;
}
The loop in this testcase is compiled with 'gcc -O2 -ftree-vectorize -msse2'
into:
.L2:
movdqa ib(%eax), %xmm0
paddw ic(%eax), %xmm0
incl %edx
movdqa %xmm0, ia(%eax)
addl $16, %eax
cmpl $2, %edx
jne .L2
There is no (,%reg,16) SIB mode available in i386, and it looks to me that loop
optimizer fallbacks to the most simple addressing mode in this case.
Unfortunatelly, %edx register is wasted in above code.
A better code would be:
.L2:
movdqa ib(,%eax,8), %xmm0
paddw ic(,%eax,8), %xmm0
movdqa %xmm0, ia(,%eax,8)
addl $2, %eax
cmpl $4, %eax
jne .L2
or with the simplest addressing scheme:
.L2:
movdqa ib(%eax), %xmm0
paddw ic(%eax), %xmm0
movdqa %xmm0, ia(%eax)
addl $16, %eax
cmpl $32, %eax
jne .L2
Uros.
--
Summary: A register is wasted in simple vectorised loops
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P2
Component: target
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: uros at kss-loka dot si
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22497
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/22497] A register is wasted in simple vectorised loops
2005-07-15 10:09 [Bug target/22497] New: A register is wasted in simple vectorised loops uros at kss-loka dot si
@ 2005-07-15 22:19 ` pinskia at gcc dot gnu dot org
2005-07-18 6:43 ` uros at kss-loka dot si
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-15 22:19 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-07-15 22:18 -------
With last night's compiler I get:
.L2:
movdqa ib(,%eax,8), %xmm0
paddw ic(,%eax,8), %xmm0
movdqa %xmm0, ia(,%eax,8)
addl $2, %eax
cmpl $4, %eax
jne .L2
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22497
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/22497] A register is wasted in simple vectorised loops
2005-07-15 10:09 [Bug target/22497] New: A register is wasted in simple vectorised loops uros at kss-loka dot si
2005-07-15 22:19 ` [Bug target/22497] " pinskia at gcc dot gnu dot org
@ 2005-07-18 6:43 ` uros at kss-loka dot si
2005-07-18 7:18 ` pinskia at gcc dot gnu dot org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: uros at kss-loka dot si @ 2005-07-18 6:43 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From uros at kss-loka dot si 2005-07-18 06:36 -------
(In reply to comment #1)
> With last night's compiler I get:
Strange...
I have tested gcc snapshot 'gcc version 4.1.0 20050716 (experimental)',
with 'gcc -O2 -ftree-vectorize -msse2' and it still produces code with both %
eax and %edx used.
Andrew, which gcc version and compile flags have you used to produce your asm
code?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22497
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/22497] A register is wasted in simple vectorised loops
2005-07-15 10:09 [Bug target/22497] New: A register is wasted in simple vectorised loops uros at kss-loka dot si
2005-07-15 22:19 ` [Bug target/22497] " pinskia at gcc dot gnu dot org
2005-07-18 6:43 ` uros at kss-loka dot si
@ 2005-07-18 7:18 ` pinskia at gcc dot gnu dot org
2005-07-22 10:32 ` uros at kss-loka dot si
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-18 7:18 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-07-18 06:49 -------
(In reply to comment #2)
> I have tested gcc snapshot 'gcc version 4.1.0 20050716 (experimental)',
> with 'gcc -O2 -ftree-vectorize -msse2' and it still produces code with both %
> eax and %edx used.
>
> Andrew, which gcc version and compile flags have you used to produce your asm
> code?
Oh, I have a local patch which will cause this, woops:
Index: config/i386/i386.c
===============================================================
====
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.c,v
retrieving revision 1.842
diff -u -p -r1.842 i386.c
--- config/i386/i386.c 14 Jul 2005 07:46:16 -0000 1.842
+++ config/i386/i386.c 18 Jul 2005 06:48:33 -0000
@@ -5044,6 +5044,10 @@ ix86_address_cost (rtx x)
/* More complex memory references are better. */
if (parts.disp && parts.disp != const0_rtx)
cost--;
+
+ if (parts.scale != 1)
+ cost--;
+
if (parts.seg != SEG_DEFAULT)
cost--;
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Last reconfirmed|0000-00-00 00:00:00 |2005-07-18 06:49:26
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22497
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/22497] A register is wasted in simple vectorised loops
2005-07-15 10:09 [Bug target/22497] New: A register is wasted in simple vectorised loops uros at kss-loka dot si
` (2 preceding siblings ...)
2005-07-18 7:18 ` pinskia at gcc dot gnu dot org
@ 2005-07-22 10:32 ` uros at kss-loka dot si
2005-09-28 8:15 ` uros at kss-loka dot si
2005-09-28 8:17 ` uros at kss-loka dot si
5 siblings, 0 replies; 7+ messages in thread
From: uros at kss-loka dot si @ 2005-07-22 10:32 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From uros at kss-loka dot si 2005-07-22 09:41 -------
(In reply to comment #3)
> Oh, I have a local patch which will cause this, woops:
> + if (parts.scale != 1)
> + cost--;
> +
> if (parts.seg != SEG_DEFAULT)
> cost--;
Do you plan to submit this patch to gcc-patches? It sure optimizes some code,
and the testcase from decription could be used to show benefits of this patch.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22497
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/22497] A register is wasted in simple vectorised loops
2005-07-15 10:09 [Bug target/22497] New: A register is wasted in simple vectorised loops uros at kss-loka dot si
` (3 preceding siblings ...)
2005-07-22 10:32 ` uros at kss-loka dot si
@ 2005-09-28 8:15 ` uros at kss-loka dot si
2005-09-28 8:17 ` uros at kss-loka dot si
5 siblings, 0 replies; 7+ messages in thread
From: uros at kss-loka dot si @ 2005-09-28 8:15 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From uros at kss-loka dot si 2005-09-28 08:14 -------
The problem was fixed by the patch for PR 18463:
http://gcc.gnu.org/ml/gcc-patches/2005-09/msg01159.html
--
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22497
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug target/22497] A register is wasted in simple vectorised loops
2005-07-15 10:09 [Bug target/22497] New: A register is wasted in simple vectorised loops uros at kss-loka dot si
` (4 preceding siblings ...)
2005-09-28 8:15 ` uros at kss-loka dot si
@ 2005-09-28 8:17 ` uros at kss-loka dot si
5 siblings, 0 replies; 7+ messages in thread
From: uros at kss-loka dot si @ 2005-09-28 8:17 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |4.1.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22497
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2005-09-28 8:17 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-15 10:09 [Bug target/22497] New: A register is wasted in simple vectorised loops uros at kss-loka dot si
2005-07-15 22:19 ` [Bug target/22497] " pinskia at gcc dot gnu dot org
2005-07-18 6:43 ` uros at kss-loka dot si
2005-07-18 7:18 ` pinskia at gcc dot gnu dot org
2005-07-22 10:32 ` uros at kss-loka dot si
2005-09-28 8:15 ` uros at kss-loka dot si
2005-09-28 8:17 ` uros at kss-loka dot si
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).