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: Fix for c++/14425 and c++/14426


This fixes the AltiVec splat bogosities discovered by Tim; I've also
added Tim's examples to the test suite.  The main thrust of the
change is to relax the types of numeric literal arguments to 'int'
(where they haven't been already), since the expansion logic checks
for valid value ranges anyway.

I'll commit this shortly, barring substantive objections.

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

PR c++/14425, c++/14426
* config/rs6000/altivec.h (vec_splat_s8, vec_splat_s16,
vec_splat_s32, vec_splat_u8, vec_splat_u16, vec_splat_u32):
Change C++ definitions to accept a 'const int' argument;
the prototypes already do.
* config/rs6000/rs6000.c (rs6000_common_init_builtins):
Rename v4si_ftype_char, v8hi_ftype_char, v16qi_ftype_char,
v4sf_ftype_v4si_char, v4si_ftype_v4sf_char, v4si_ftype_v4si_char,
v8hi_ftype_v8hi_char, v16qi_ftype_v16qi_char,
v16qi_ftype_v16qi_v16qi_char, v8hi_ftype_v8hi_v8hi_char,
v4si_ftype_v4si_v4si_char and v4sf_ftype_v4sf_v4sf_char to
end in ..._int; change them to accept an int instead of a char
as the last parameter.


[gcc/testsuite/ChangeLog]
2004-03-04  Ziemowit Laski  <zlaski@apple.com>

        PR c++/14425, c++/14426
        * g++.dg/ext/altivec-4.C: New test.
        * g++.dg/ext/altivec-5.C: New test.

Index: gcc/config/rs6000/altivec.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/altivec.h,v
retrieving revision 1.28
diff -u -3 -p -r1.28 altivec.h
--- gcc/config/rs6000/altivec.h 21 Feb 2004 09:08:35 -0000      1.28
+++ gcc/config/rs6000/altivec.h 4 Mar 2004 22:45:30 -0000
@@ -4613,7 +4613,7 @@ vec_vspltb (vector unsigned char a1, con
 /* vec_splat_s8 */

 inline vector signed char
-vec_splat_s8 (const signed char a1)
+vec_splat_s8 (const int a1)
 {
   return (vector signed char) __builtin_altivec_vspltisb (a1);
 }
@@ -4621,7 +4621,7 @@ vec_splat_s8 (const signed char a1)
 /* vec_splat_s16 */

 inline vector signed short
-vec_splat_s16 (const signed char a1)
+vec_splat_s16 (const int a1)
 {
   return (vector signed short) __builtin_altivec_vspltish (a1);
 }
@@ -4629,7 +4629,7 @@ vec_splat_s16 (const signed char a1)
 /* vec_splat_s32 */

 inline vector signed int
-vec_splat_s32 (const signed char a1)
+vec_splat_s32 (const int a1)
 {
   return (vector signed int) __builtin_altivec_vspltisw (a1);
 }
@@ -4637,7 +4637,7 @@ vec_splat_s32 (const signed char a1)
 /* vec_splat_u8 */

 inline vector unsigned char
-vec_splat_u8 (const signed char a1)
+vec_splat_u8 (const int a1)
 {
   return (vector unsigned char) __builtin_altivec_vspltisb (a1);
 }
@@ -4645,7 +4645,7 @@ vec_splat_u8 (const signed char a1)
 /* vec_splat_u16 */

 inline vector unsigned short
-vec_splat_u16 (const signed char a1)
+vec_splat_u16 (const int a1)
 {
   return (vector unsigned short) __builtin_altivec_vspltish (a1);
 }
@@ -4653,7 +4653,7 @@ vec_splat_u16 (const signed char a1)
 /* vec_splat_u32 */

inline vector unsigned int
-vec_splat_u32 (const signed char a1)
+vec_splat_u32 (const int a1)
{
return (vector unsigned int) __builtin_altivec_vspltisw (a1);
}
Index: gcc/config/rs6000/rs6000.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/rs6000.c,v
retrieving revision 1.600
diff -u -3 -p -r1.600 rs6000.c
--- gcc/config/rs6000/rs6000.c 4 Mar 2004 15:28:59 -0000 1.600
+++ gcc/config/rs6000/rs6000.c 4 Mar 2004 22:45:31 -0000
@@ -7015,12 +7015,12 @@ rs6000_common_init_builtins (void)
= build_function_type_list (V16QI_type_node,
V16QI_type_node, V16QI_type_node,
V16QI_type_node, NULL_TREE);
- tree v4si_ftype_char
- = build_function_type_list (V4SI_type_node, char_type_node, NULL_TREE);
- tree v8hi_ftype_char
- = build_function_type_list (V8HI_type_node, char_type_node, NULL_TREE);
- tree v16qi_ftype_char
- = build_function_type_list (V16QI_type_node, char_type_node, NULL_TREE);
+ tree v4si_ftype_int
+ = build_function_type_list (V4SI_type_node, integer_type_node, NULL_TREE);
+ tree v8hi_ftype_int
+ = build_function_type_list (V8HI_type_node, integer_type_node, NULL_TREE);
+ tree v16qi_ftype_int
+ = build_function_type_list (V16QI_type_node, integer_type_node, NULL_TREE);
tree v8hi_ftype_v16qi
= build_function_type_list (V8HI_type_node, V16QI_type_node, NULL_TREE);
tree v4sf_ftype_v4sf
@@ -7078,37 +7078,37 @@ rs6000_common_init_builtins (void)
tree v4si_ftype_v4si_v4si
= build_function_type_list (V4SI_type_node,
V4SI_type_node, V4SI_type_node, NULL_TREE);
- tree v4sf_ftype_v4si_char
+ tree v4sf_ftype_v4si_int
= build_function_type_list (V4SF_type_node,
- V4SI_type_node, char_type_node, NULL_TREE);
- tree v4si_ftype_v4sf_char
+ V4SI_type_node, integer_type_node, NULL_TREE);
+ tree v4si_ftype_v4sf_int
= build_function_type_list (V4SI_type_node,
- V4SF_type_node, char_type_node, NULL_TREE);
- tree v4si_ftype_v4si_char
+ V4SF_type_node, integer_type_node, NULL_TREE);
+ tree v4si_ftype_v4si_int
= build_function_type_list (V4SI_type_node,
- V4SI_type_node, char_type_node, NULL_TREE);
- tree v8hi_ftype_v8hi_char
+ V4SI_type_node, integer_type_node, NULL_TREE);
+ tree v8hi_ftype_v8hi_int
= build_function_type_list (V8HI_type_node,
- V8HI_type_node, char_type_node, NULL_TREE);
- tree v16qi_ftype_v16qi_char
+ V8HI_type_node, integer_type_node, NULL_TREE);
+ tree v16qi_ftype_v16qi_int
= build_function_type_list (V16QI_type_node,
- V16QI_type_node, char_type_node, NULL_TREE);
- tree v16qi_ftype_v16qi_v16qi_char
+ V16QI_type_node, integer_type_node, NULL_TREE);
+ tree v16qi_ftype_v16qi_v16qi_int
= build_function_type_list (V16QI_type_node,
V16QI_type_node, V16QI_type_node,
- char_type_node, NULL_TREE);
- tree v8hi_ftype_v8hi_v8hi_char
+ integer_type_node, NULL_TREE);
+ tree v8hi_ftype_v8hi_v8hi_int
= build_function_type_list (V8HI_type_node,
V8HI_type_node, V8HI_type_node,
- char_type_node, NULL_TREE);
- tree v4si_ftype_v4si_v4si_char
+ integer_type_node, NULL_TREE);
+ tree v4si_ftype_v4si_v4si_int
= build_function_type_list (V4SI_type_node,
V4SI_type_node, V4SI_type_node,
- char_type_node, NULL_TREE);
- tree v4sf_ftype_v4sf_v4sf_char
+ integer_type_node, NULL_TREE);
+ tree v4sf_ftype_v4sf_v4sf_int
= build_function_type_list (V4SF_type_node,
V4SF_type_node, V4SF_type_node,
- char_type_node, NULL_TREE);
+ integer_type_node, NULL_TREE);
tree v4sf_ftype_v4sf_v4sf
= build_function_type_list (V4SF_type_node,
V4SF_type_node, V4SF_type_node, NULL_TREE);
@@ -7251,22 +7251,22 @@ rs6000_common_init_builtins (void)
/* vchar, vchar, vchar, 4 bit literal. */
else if (mode0 == V16QImode && mode1 == mode0 && mode2 == mode0
&& mode3 == QImode)
- type = v16qi_ftype_v16qi_v16qi_char;
+ type = v16qi_ftype_v16qi_v16qi_int;


       /* vshort, vshort, vshort, 4 bit literal.  */
       else if (mode0 == V8HImode && mode1 == mode0 && mode2 == mode0
               && mode3 == QImode)
-       type = v8hi_ftype_v8hi_v8hi_char;
+       type = v8hi_ftype_v8hi_v8hi_int;

       /* vint, vint, vint, 4 bit literal.  */
       else if (mode0 == V4SImode && mode1 == mode0 && mode2 == mode0
               && mode3 == QImode)
-       type = v4si_ftype_v4si_v4si_char;
+       type = v4si_ftype_v4si_v4si_int;

       /* vfloat, vfloat, vfloat, 4 bit literal.  */
       else if (mode0 == V4SFmode && mode1 == mode0 && mode2 == mode0
               && mode3 == QImode)
-       type = v4sf_ftype_v4sf_v4sf_char;
+       type = v4sf_ftype_v4sf_v4sf_int;

       else
        abort ();
@@ -7355,23 +7355,23 @@ rs6000_common_init_builtins (void)

/* vint, vint, 5 bit literal. */
else if (mode0 == V4SImode && mode1 == V4SImode && mode2 == QImode)
- type = v4si_ftype_v4si_char;
+ type = v4si_ftype_v4si_int;


/* vshort, vshort, 5 bit literal. */
else if (mode0 == V8HImode && mode1 == V8HImode && mode2 == QImode)
- type = v8hi_ftype_v8hi_char;
+ type = v8hi_ftype_v8hi_int;


/* vchar, vchar, 5 bit literal. */
else if (mode0 == V16QImode && mode1 == V16QImode && mode2 == QImode)
- type = v16qi_ftype_v16qi_char;
+ type = v16qi_ftype_v16qi_int;


/* vfloat, vint, 5 bit literal. */
else if (mode0 == V4SFmode && mode1 == V4SImode && mode2 == QImode)
- type = v4sf_ftype_v4si_char;
+ type = v4sf_ftype_v4si_int;


/* vint, vfloat, 5 bit literal. */
else if (mode0 == V4SImode && mode1 == V4SFmode && mode2 == QImode)
- type = v4si_ftype_v4sf_char;
+ type = v4si_ftype_v4sf_int;


       else if (mode0 == V2SImode && mode1 == SImode && mode2 == SImode)
        type = v2si_ftype_int_int;
@@ -7424,11 +7424,11 @@ rs6000_common_init_builtins (void)
       mode1 = insn_data[d->icode].operand[1].mode;

if (mode0 == V4SImode && mode1 == QImode)
- type = v4si_ftype_char;
+ type = v4si_ftype_int;
else if (mode0 == V8HImode && mode1 == QImode)
- type = v8hi_ftype_char;
+ type = v8hi_ftype_int;
else if (mode0 == V16QImode && mode1 == QImode)
- type = v16qi_ftype_char;
+ type = v16qi_ftype_int;
else if (mode0 == V4SFmode && mode1 == V4SFmode)
type = v4sf_ftype_v4sf;
else if (mode0 == V8HImode && mode1 == V16QImode)
Index: gcc/testsuite/g++.dg/ext/altivec-4.C
===================================================================
RCS file: gcc/testsuite/g++.dg/ext/altivec-4.C
diff -N gcc/testsuite/g++.dg/ext/altivec-4.C
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gcc/testsuite/g++.dg/ext/altivec-4.C 4 Mar 2004 22:45:33 -0000
@@ -0,0 +1,11 @@
+/* { dg-do compile { target powerpc*-*-* } } */
+/* { dg-options "-maltivec" } */
+
+/* PR c++/14425 */
+
+#include <altivec.h>
+
+vector unsigned int splat0(vector unsigned int x)
+{
+ return vec_splat(x, 0);
+}
Index: gcc/testsuite/g++.dg/ext/altivec-5.C
===================================================================
RCS file: gcc/testsuite/g++.dg/ext/altivec-5.C
diff -N gcc/testsuite/g++.dg/ext/altivec-5.C
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gcc/testsuite/g++.dg/ext/altivec-5.C 4 Mar 2004 22:45:33 -0000
@@ -0,0 +1,15 @@
+/* { dg-do compile { target powerpc*-*-* } } */
+/* { dg-options "-maltivec" } */
+
+/* PR c++/14426 */
+
+#include <altivec.h>
+
+vector unsigned int splat0u()
+{
+ return vec_splat_u32(0);
+}
+vector int splat0s()
+{
+ return vec_splat_s32(0);
+}


--------------------------------------------------------------
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]