public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/19133] New: march=athlon can produce slower code than march=i686
@ 2004-12-22 21:01 ornati at fastwebnet dot it
  2004-12-22 21:05 ` [Bug target/19133] " pinskia at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: ornati at fastwebnet dot it @ 2004-12-22 21:01 UTC (permalink / raw)
  To: gcc-bugs

"gcc -v"
Reading specs from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/specs
Configured with: /var/tmp/portage/gcc-3.3.4-r1/work/gcc-3.3.4/configure
--prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/3.3
--includedir=/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/include
--datadir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3
--mandir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3/man
--infodir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3/info --enable-shared
--host=i686-pc-linux-gnu --target=i686-pc-linux-gnu --with-system-zlib
--enable-languages=c,c++ --enable-threads=posix --enable-long-long
--disable-checking --disable-libunwind-exceptions --enable-cstdio=stdio
--enable-version-specific-runtime-libs
--with-gxx-include-dir=/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/include/g++-v3
--with-local-prefix=/usr/local --enable-shared --enable-nls
--without-included-gettext --disable-multilib --enable-__cxa_atexit
--enable-clocale=generic
Thread model: posix
gcc version 3.3.4 20040623 (Gentoo Linux 3.3.4-r1, ssp-3.3.2-2, pie-8.7.6)


"cat /proc/cpu"
processor	: 0
vendor_id	: AuthenticAMD
cpu family	: 6
model		: 3
model name	: AMD Duron(tm) Processor
stepping	: 1
cpu MHz		: 756.798
cache size	: 64 KB
fdiv_bug	: no
hlt_bug		: no
f00f_bug	: no
coma_bug	: no
fpu		: yes
fpu_exception	: yes
cpuid level	: 1
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 sep mtrr pge mca cmov pat pse36 mmx
fxsr syscall mmxext 3dnowext 3dnow
bogomips	: 1490.94


Playing with compiler optimizations I've found a "test-case" where
"-march=athlon" produces an executable that is ~18% slower than that produced
with "-march=i686".

"Commands used for compilation"
gcc -Wall -O2 -march=i686 -o test-i686 test.c
gcc -Wall -O2 -march=athlon -o test-athlon test.c

"test.c"
#define N 30000

static int A[N];
static int B[N];

int main(void)
{
	int i, j, x;

	for (i = 0; i < N; ++i) {
		x = 0;
		for (j=0; j < N; ++j)
			if (A[j] < A[i] && B[j] > x)
				x = A[j];
		A[i] = x + 1;
	}
	return 0;
}


Execution time:

paolo@tux gcc_test $ time ./test-i686 

real    0m6.149s
user    0m6.015s
sys     0m0.004s
paolo@tux gcc_test $ time ./test-athlon 

real    0m7.270s
user    0m7.120s
sys     0m0.004s


Anoter interesting thing is that if I only do this change:
--- test.c.orig	2004-12-22 21:52:46.208140096 +0100
+++ test.c	2004-12-22 21:55:01.069638032 +0100
@@ -10,7 +10,7 @@
 	for (i = 0; i < N; ++i) {
 		x = 0;
 		for (j=0; j < N; ++j)
-			if (A[j] < A[i] && B[j] > x)
+			if (A[j] < A[i] && A[j] > x)
 				x = A[j];
 		A[i] = x + 1;
 	}


The "test-athlon" version returns fast as "test-i686" one:

paolo@tux gcc_test $ time ./test-i686 

real    0m6.134s
user    0m6.015s
sys     0m0.003s
paolo@tux gcc_test $ time ./test-athlon 

real    0m6.128s
user    0m6.010s
sys     0m0.006s


I've tried also gcc 3.4.3 and it shows the same behaviour.

Shouldn't "-march=athlon" optimize for AMD K7 processors? ;-)

-- 
           Summary: march=athlon can produce slower code than march=i686
           Product: gcc
           Version: 3.3.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ornati at fastwebnet dot it
                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=19133


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

* [Bug target/19133] march=athlon can produce slower code than march=i686
  2004-12-22 21:01 [Bug c/19133] New: march=athlon can produce slower code than march=i686 ornati at fastwebnet dot it
@ 2004-12-22 21:05 ` pinskia at gcc dot gnu dot org
  2005-02-08 16:37 ` steven at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-12-22 21:05 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c                           |target
           Keywords|                            |missed-optimization


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


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

* [Bug target/19133] march=athlon can produce slower code than march=i686
  2004-12-22 21:01 [Bug c/19133] New: march=athlon can produce slower code than march=i686 ornati at fastwebnet dot it
  2004-12-22 21:05 ` [Bug target/19133] " pinskia at gcc dot gnu dot org
@ 2005-02-08 16:37 ` steven at gcc dot gnu dot org
  2005-02-08 23:18 ` ornati at fastwebnet dot it
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: steven at gcc dot gnu dot org @ 2005-02-08 16:37 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From steven at gcc dot gnu dot org  2005-02-08 10:09 -------
-march=athlon should optimize for the K7 yes.  What you probably run into
is a simple backend problem where the code generated for the K7 can, for
whatever reason, not be optimized as well as the i686 code.

Can you try mainline and see what happens there?  I think very few people
think this is important enough to fix for already-released compilers.  But
if the problem exists on mainline as well, we can look into it.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2005-02-08 10:09:23
               date|                            |


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


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

* [Bug target/19133] march=athlon can produce slower code than march=i686
  2004-12-22 21:01 [Bug c/19133] New: march=athlon can produce slower code than march=i686 ornati at fastwebnet dot it
  2004-12-22 21:05 ` [Bug target/19133] " pinskia at gcc dot gnu dot org
  2005-02-08 16:37 ` steven at gcc dot gnu dot org
@ 2005-02-08 23:18 ` ornati at fastwebnet dot it
  2005-05-07 13:54 ` steven at gcc dot gnu dot org
  2005-05-07 14:04 ` ornati at fastwebnet dot it
  4 siblings, 0 replies; 6+ messages in thread
From: ornati at fastwebnet dot it @ 2005-02-08 23:18 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From ornati at fastwebnet dot it  2005-02-08 16:13 -------
gcc -v

Using built-in specs.
Configured with:
/var/tmp/portage/gcc-4.0.0_alpha20050130/work/gcc-4.0-20050130/configure
--enable-version-specific-runtime-libs --prefix=/usr
--bindir=/usr/i686-pc-linux-gnu/gcc-bin/4.0.0
--includedir=/usr/lib/gcc/i686-pc-linux-gnu/4.0.0/include
--datadir=/usr/share/gcc-data/i686-pc-linux-gnu/4.0.0
--mandir=/usr/share/gcc-data/i686-pc-linux-gnu/4.0.0/man
--infodir=/usr/share/gcc-data/i686-pc-linux-gnu/4.0.0/info
--with-gxx-include-dir=/usr/lib/gcc/i686-pc-linux-gnu/4.0.0/include/g++-v4
--host=i686-pc-linux-gnu --disable-altivec --enable-nls
--without-included-gettext --enable-__cxa_atexit --enable-clocale=gnu
--with-system-zlib --disable-checking --disable-werror
--disable-libunwind-exceptions --enable-shared --enable-threads=posix
--disable-multilib --disable-libgcj --enable-languages=c,c++
Thread model: posix
gcc version 4.0.0 alpha20050130 (Gentoo Linux 4.0.0_alpha20050130)


paolo@tux gcc_test $ time ./test-i686 

real    0m8.539s
user    0m8.376s
sys     0m0.001s
paolo@tux gcc_test $ time ./test-athlon 

real    0m6.168s
user    0m6.031s
sys     0m0.005s


As the numbers show, the problem go away for "-march=athlon"... but now
"-march=i686" version is MUCH slower than before (with GCC 3.3.x).

Seems like I've found a very strange test-case...

-- 


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


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

* [Bug target/19133] march=athlon can produce slower code than march=i686
  2004-12-22 21:01 [Bug c/19133] New: march=athlon can produce slower code than march=i686 ornati at fastwebnet dot it
                   ` (2 preceding siblings ...)
  2005-02-08 23:18 ` ornati at fastwebnet dot it
@ 2005-05-07 13:54 ` steven at gcc dot gnu dot org
  2005-05-07 14:04 ` ornati at fastwebnet dot it
  4 siblings, 0 replies; 6+ messages in thread
From: steven at gcc dot gnu dot org @ 2005-05-07 13:54 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From steven at gcc dot gnu dot org  2005-05-07 13:54 -------
Looks like random instruction selection weirdness. 
Not much can be done about this. 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WONTFIX


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


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

* [Bug target/19133] march=athlon can produce slower code than march=i686
  2004-12-22 21:01 [Bug c/19133] New: march=athlon can produce slower code than march=i686 ornati at fastwebnet dot it
                   ` (3 preceding siblings ...)
  2005-05-07 13:54 ` steven at gcc dot gnu dot org
@ 2005-05-07 14:04 ` ornati at fastwebnet dot it
  4 siblings, 0 replies; 6+ messages in thread
From: ornati at fastwebnet dot it @ 2005-05-07 14:04 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From ornati at fastwebnet dot it  2005-05-07 14:04 -------
ok

-- 


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


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

end of thread, other threads:[~2005-05-07 14:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-22 21:01 [Bug c/19133] New: march=athlon can produce slower code than march=i686 ornati at fastwebnet dot it
2004-12-22 21:05 ` [Bug target/19133] " pinskia at gcc dot gnu dot org
2005-02-08 16:37 ` steven at gcc dot gnu dot org
2005-02-08 23:18 ` ornati at fastwebnet dot it
2005-05-07 13:54 ` steven at gcc dot gnu dot org
2005-05-07 14:04 ` ornati at fastwebnet dot it

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).