This is the mail archive of the gcc-patches@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]

PATCH: More AltiVec builtin/argument combinations


Namely,

vector bool char vec_sld (vector bool char, vector bool char, const int);
vector bool short vec_sld (vector bool short, vector bool short, const int);
vector bool int vec_sld (vector bool int, vector bool int, const int);


Although you will not find these in the Motorola AltiVec PIM manual, they have
been in Apple's gcc, as well as MrC and CodeWarrior compilers since time
immemorial.


I will wait a nanosecond for comments, and then commit as obvious and harmless.

--Zem

[gcc/ChangeLog]
2004-05-10  Ziemowit Laski  <zlaski@apple.com>

        * config/rs6000/altivec.h (vec_sld): Add overloads for
        argument/return types of 'vector bool int', 'vector bool short'
        and 'vector bool char'.

2004-05-10 Ziemowit Laski <zlaski@apple.com>

        * g++.dg/ext/altivec-8.C: New test case.
        * gcc.dg/altivec-13.c: New test case.


Index: gcc/config/rs6000/altivec.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/altivec.h,v
retrieving revision 1.34
diff -u -3 -p -r1.34 altivec.h
--- gcc/config/rs6000/altivec.h 8 May 2004 05:02:55 -0000 1.34
+++ gcc/config/rs6000/altivec.h 10 May 2004 21:58:54 -0000
@@ -200,11 +200,14 @@ inline void vec_dstt (const float *, int
inline vector float vec_sld (vector float, vector float, const int) __attribute__ ((always_inline));
inline vector signed int vec_sld (vector signed int, vector signed int, const int) __attribute__ ((always_inline));
inline vector unsigned int vec_sld (vector unsigned int, vector unsigned int, const int) __attribute__ ((always_inline));
+inline vector bool int vec_sld (vector bool int, vector bool int, const int) __attribute__ ((always_inline));
inline vector signed short vec_sld (vector signed short, vector signed short, const int) __attribute__ ((always_inline));
inline vector unsigned short vec_sld (vector unsigned short, vector unsigned short, const int) __attribute__ ((always_inline));
+inline vector bool short vec_sld (vector bool short, vector bool short, const int) __attribute__ ((always_inline));
inline vector pixel vec_sld (vector pixel, vector pixel, const int) __attribute__ ((always_inline));
inline vector signed char vec_sld (vector signed char, vector signed char, const int) __attribute__ ((always_inline));
inline vector unsigned char vec_sld (vector unsigned char, vector unsigned char, const int) __attribute__ ((always_inline));
+inline vector bool char vec_sld (vector bool char, vector bool char, const int) __attribute__ ((always_inline));
inline vector signed char vec_splat (vector signed char, const int) __attribute__ ((always_inline));
inline vector unsigned char vec_splat (vector unsigned char, const int) __attribute__ ((always_inline));
inline vector bool char vec_splat (vector bool char, const int) __attribute__ ((always_inline));
@@ -4196,6 +4199,12 @@ vec_sld (vector unsigned int a1, vector
return (vector unsigned int) __builtin_altivec_vsldoi_4si ((vector signed int) a1, (vector signed int) a2, a3);
}


+inline vector bool int
+vec_sld (vector bool int a1, vector bool int a2, const int a3)
+{
+ return (vector bool int) __builtin_altivec_vsldoi_4si ((vector signed int) a1, (vector signed int) a2, a3);
+}
+
inline vector signed short
vec_sld (vector signed short a1, vector signed short a2, const int a3)
{
@@ -4208,6 +4217,12 @@ vec_sld (vector unsigned short a1, vecto
return (vector unsigned short) __builtin_altivec_vsldoi_4si ((vector signed int) a1, (vector signed int) a2, a3);
}


+inline vector bool short
+vec_sld (vector bool short a1, vector bool short a2, const int a3)
+{
+ return (vector bool short) __builtin_altivec_vsldoi_4si ((vector signed int) a1, (vector signed int) a2, a3);
+}
+
inline vector pixel
vec_sld (vector pixel a1, vector pixel a2, const int a3)
{
@@ -4226,6 +4241,12 @@ vec_sld (vector unsigned char a1, vector
return (vector unsigned char) __builtin_altivec_vsldoi_4si ((vector signed int) a1, (vector signed int) a2, a3);
}


+inline vector bool char
+vec_sld (vector bool char a1, vector bool char a2, const int a3)
+{
+ return (vector bool char) __builtin_altivec_vsldoi_4si ((vector signed int) a1, (vector signed int) a2, a3);
+}
+
/* vec_sll */


inline vector signed int
@@ -9534,17 +9555,23 @@ __ch (__tern_args_eq (vector signed int,
((vector signed int) __builtin_altivec_vsldoi_4si ((vector signed int) (a1), (vector signed int) (a2), (const int) (a3))), \
__ch (__tern_args_eq (vector unsigned int, (a1), vector unsigned int, (a2), int, (a3)), \
((vector unsigned int) __builtin_altivec_vsldoi_4si ((vector signed int) (a1), (vector signed int) (a2), (const int) (a3))), \
+__ch (__tern_args_eq (vector bool int, (a1), vector bool int, (a2), int, (a3)), \
+ ((vector bool int) __builtin_altivec_vsldoi_4si ((vector signed int) (a1), (vector signed int) (a2), (const int) (a3))), \
__ch (__tern_args_eq (vector signed short, (a1), vector signed short, (a2), int, (a3)), \
((vector signed short) __builtin_altivec_vsldoi_4si ((vector signed int) (a1), (vector signed int) (a2), (const int) (a3))), \
__ch (__tern_args_eq (vector unsigned short, (a1), vector unsigned short, (a2), int, (a3)), \
((vector unsigned short) __builtin_altivec_vsldoi_4si ((vector signed int) (a1), (vector signed int) (a2), (const int) (a3))), \
+__ch (__tern_args_eq (vector bool short, (a1), vector bool short, (a2), int, (a3)), \
+ ((vector bool short) __builtin_altivec_vsldoi_4si ((vector signed int) (a1), (vector signed int) (a2), (const int) (a3))), \
__ch (__tern_args_eq (vector pixel, (a1), vector pixel, (a2), int, (a3)), \
((vector pixel) __builtin_altivec_vsldoi_4si ((vector signed int) (a1), (vector signed int) (a2), (const int) (a3))), \
__ch (__tern_args_eq (vector signed char, (a1), vector signed char, (a2), int, (a3)), \
((vector signed char) __builtin_altivec_vsldoi_4si ((vector signed int) (a1), (vector signed int) (a2), (const int) (a3))), \
__ch (__tern_args_eq (vector unsigned char, (a1), vector unsigned char, (a2), int, (a3)), \
((vector unsigned char) __builtin_altivec_vsldoi_4si ((vector signed int) (a1), (vector signed int) (a2), (const int) (a3))), \
- __builtin_altivec_compiletime_error ("vec_sld")))))))))
+__ch (__tern_args_eq (vector bool char, (a1), vector bool char, (a2), int, (a3)), \
+ ((vector bool char) __builtin_altivec_vsldoi_4si ((vector signed int) (a1), (vector signed int) (a2), (const int) (a3))), \
+ __builtin_altivec_compiletime_error ("vec_sld"))))))))))))


#define vec_sll(a1, a2) \
__ch (__bin_args_eq (vector signed int, (a1), vector unsigned int, (a2)), \
Index: gcc/testsuite/g++.dg/ext/altivec-8.C
===================================================================
RCS file: gcc/testsuite/g++.dg/ext/altivec-8.C
diff -N gcc/testsuite/g++.dg/ext/altivec-8.C
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gcc/testsuite/g++.dg/ext/altivec-8.C 10 May 2004 21:58:58 -0000
@@ -0,0 +1,16 @@
+/* { dg-do compile { target powerpc*-*-* } } */
+/* { dg-options "-faltivec" } */
+/* Author: Ziemowit Laski <zlaski@apple.com> */
+
+/* This test case exercises intrinsic/argument combinations that,
+ while not in the Motorola AltiVec PIM, have nevertheless crept
+ into the AltiVec vernacular over the years. */
+
+void foo() {
+ vector bool int boolVec1 = (vector bool int) vec_splat_u32(3);
+ vector bool short boolVec2 = (vector bool short) vec_splat_u16(3);
+ vector bool char boolVec3 = (vector bool char) vec_splat_u8(3);
+ boolVec1 = vec_sld( boolVec1, boolVec1, 4 );
+ boolVec2 = vec_sld( boolVec2, boolVec2, 2 );
+ boolVec3 = vec_sld( boolVec3, boolVec3, 1 );
+}
Index: gcc/testsuite/gcc.dg/altivec-13.c
===================================================================
RCS file: gcc/testsuite/gcc.dg/altivec-13.c
diff -N gcc/testsuite/gcc.dg/altivec-13.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gcc/testsuite/gcc.dg/altivec-13.c 10 May 2004 21:59:06 -0000
@@ -0,0 +1,16 @@
+/* { dg-do compile { target powerpc*-*-* } } */
+/* { dg-options "-faltivec" } */
+/* Author: Ziemowit Laski <zlaski@apple.com> */
+
+/* This test case exercises intrinsic/argument combinations that,
+ while not in the Motorola AltiVec PIM, have nevertheless crept
+ into the AltiVec vernacular over the years. */
+
+void foo() {
+ vector bool int boolVec1 = (vector bool int) vec_splat_u32(3);
+ vector bool short boolVec2 = (vector bool short) vec_splat_u16(3);
+ vector bool char boolVec3 = (vector bool char) vec_splat_u8(3);
+ boolVec1 = vec_sld( boolVec1, boolVec1, 4 );
+ boolVec2 = vec_sld( boolVec2, boolVec2, 2 );
+ boolVec3 = vec_sld( boolVec3, boolVec3, 1 );
+}


--------------------------------------------------------------
Ziemowit Laski                 1 Infinite Loop, MS 301-2K
Mac OS X Compiler Group        Cupertino, CA USA  95014-2083
Apple Computer, Inc.           +1.408.974.6229  Fax .5477


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