This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: serious bugs in Altivec implementation of gcc


hello
The max patch is working - thanks.
The problem with vec_msum still exist, the same problem occurs when I use vec_vmsummbm instead of vec_msum - could the problem be somewhere in the implementation of __builtin_altivec_vmsummbm ? ( by the way the altivec.h file you send me is the same as I had )

another thing that I noticed when comparing assembler code of 2 corresponding files it looks like the new gcc code is less optimised
( I attached the testMax_2.9.2.cpp and testMax_3.2.cpp and their corresponding assembler files.

I used : g++ -S -Wall -pedantic -ansi -Wno-long-long -DNDEBUG -O6 -DALTIVEC -fvec testMax_2.9.2.cpp

and : g++ -S -Wall -pedantic -ansi -Wno-long-long -DNDEBUG -O6 -DALTIVEC -maltivec testMax_3.2.cpp

Thanks
Eyal

Aldy Hernandez wrote:
On Mon, Aug 12, 2002 at 02:53:42PM +0300, Eyal Bagon wrote:

serious bugs in Altivec implementation of gcc

hello

I'm trying to use gcc 3.2 to compile C code for Altivec and I found some serious problems in the compiler:
1) vec_max is converted to the assembler function of MIN ( not MAX )
you can compile the attached file testMax.cpp
g++ -S -Wall -pedantic -ansi -Wno-long-long -DNDEBUG -O6
-DALTIVEC -maltivec testMax.cpp

you can see in the assembler file that you get vminuw instead of
vmax...

See:

http://gcc.gnu.org/ml/gcc-patches/2002-05/msg00630.html


2) vec_msum : when vec_msum is used with signed char as the first 		
	parameter the assembler code will be vmsumubm -> as for 	
	UNsigned.

		you can enjoy this yourself - just compile testMsum.cpp

Is there a patch that sole these problems ?
Is there a reliable version of gcc for Altivec ?

I can't recall, but this may be fixed on current sources.  Use the
altivec.h from CVS.  I'm attaching it just in case.  If it doesn't fix
it, ping me again and CC the gcc@gcc.gnu.org.

A few buglets were fixed from 3.2 to the CVS sources, but most of
bugfixes were in <altivec.h> so you may get away with using this new
file I'm attaching.  (except in the first bug you mention.  That
requires a patch to the sources).

Aldy

//#include <altivec.h>

__vector unsigned int testMax()
{
  __vector unsigned int vss1 = (__vector unsigned int)(1,2,3,4);
  __vector unsigned int vss2 = (__vector unsigned int)(8,7,6,5);
    
  __vector unsigned int vss3;
  
  vss3 = vec_max(vss1,vss2);

  return vss3;
    
}
  
#include <altivec.h>

__vector unsigned int testMax()
{
  __vector unsigned int vss1 = {1,2,3,4};
  __vector unsigned int vss2 = {8,7,6,5};
    
  __vector unsigned int vss3;
  
  vss3 = vec_max(vss1,vss2);

  return vss3;
    
}
	.file	"testMax_2.9.2.cpp"
gcc2_compiled.:
	.section	".rodata"
	.align 4
.LC2:
	.long 1
	.long 2
	.long 3
	.long 4
	.align 4
.LC3:
	.long 8
	.long 7
	.long 6
	.long 5
	.section	".text"
	.align 2
	.globl testMax__Fv
	.type	 testMax__Fv,@function
testMax__Fv:
.LFB1:
	lis 9,.LC2@ha
	lis 11,.LC3@ha
	la 9,.LC2@l(9)
	la 11,.LC3@l(11)
	lvx 0,0,9
	lvx 2,0,11
	vmaxuw 2,0,2
	blr
.LFE1:
.Lfe1:
	.size	 testMax__Fv,.Lfe1-testMax__Fv

	.section	".eh_frame","aw"
__FRAME_BEGIN__:
	.4byte	.LLCIE1
.LSCIE1:
	.4byte	0x0
	.byte	0x1
	.byte	0x0
	.byte	0x1
	.byte	0x7c
	.byte	0x6e
	.byte	0xc
	.byte	0x1
	.byte	0x0
	.byte	0x9
	.byte	0x6e
	.byte	0x41
	.align 2
.LECIE1:
	.set	.LLCIE1,.LECIE1-.LSCIE1
	.4byte	.LLFDE1
.LSFDE1:
	.4byte	.LSFDE1-__FRAME_BEGIN__
	.4byte	.LFB1

	.4byte	.LFE1-.LFB1
	.align 2
.LEFDE1:
	.set	.LLFDE1,.LEFDE1-.LSFDE1
	.ident	"GCC: (GNU) 2.95.2 19991024 (moto-1.7 release)"
	.file	"testMax_3.2.cpp"
	.section	.rodata
	.align 4
.LC0:
	.long	1
	.long	2
	.long	3
	.long	4
	.align 4
.LC1:
	.long	8
	.long	7
	.long	6
	.long	5
	.section	".text"
	.align 2
	.globl _Z7testMaxv
	.type	_Z7testMaxv,@function
_Z7testMaxv:
.LFB1:
	mfvrsave 8
	stwu 1,-32(1)
.LCFI0:
	oris 7,8,0xdfff
	ori 0,7,61440
	stw 8,28(1)
	mtvrsave 0
	lis 4,.LC1@ha
	lis 6,.LC0@ha
	la 3,.LC1@l(4)
	la 5,.LC0@l(6)
	lvx 3,0,3
	lvx 1,0,5
	lwz 0,28(1)
	vmaxuw 2,1,3
	mtvrsave 0
	addi 1,1,32
	blr
.LFE1:
.Lfe1:
	.size	_Z7testMaxv,.Lfe1-_Z7testMaxv
	.ident	"GCC: (GNU) 3.2 20020811 (prerelease)"

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]