pr64252.c: fix sizeof(int) assumption
diff mbox

Message ID 201506060512.t565C60R022026@greed.delorie.com
State New
Headers show

Commit Message

DJ Delorie June 6, 2015, 5:12 a.m. UTC
On targets with 2 byte "int" the vectors are 16 values long, which
breaks the index count in __builtin_shuffle() using more than one
input vector.  Ok?

	* gcc.dg/pr64252.c: Fix assumption about sizeof(int).

 2015-06-05  Thomas Koenig  <tkoenig@gcc.gnu.org>

Comments

Marc Glisse June 6, 2015, 5:50 a.m. UTC | #1
On Sat, 6 Jun 2015, DJ Delorie wrote:

> On targets with 2 byte "int" the vectors are 16 values long, which
> breaks the index count in __builtin_shuffle() using more than one
> input vector.  Ok?
>
> 	* gcc.dg/pr64252.c: Fix assumption about sizeof(int).
>
> 2015-06-05  Thomas Koenig  <tkoenig@gcc.gnu.org>
> Index: gcc.dg/pr64252.c
> ===================================================================
> --- gcc.dg/pr64252.c	(revision 224181)
> +++ gcc.dg/pr64252.c	(working copy)
> @@ -1,11 +1,11 @@
> /* PR target/64252 */
> /* { dg-do run } */
> /* { dg-options "-O2" } */
>
> -typedef unsigned int V __attribute__((vector_size (32)));
> +typedef unsigned int V __attribute__((vector_size (sizeof(unsigned long) * 8)));

Why 'unsigned long' and not 'unsigned int'? Doesn't that break platforms 
where long and int have a different size?

> __attribute__((noinline, noclone)) void
> foo (V *a, V *b, V *c, V *d, V *e)
> {
>   V t = __builtin_shuffle (*a, *b, *c);
>   V v = __builtin_shuffle (t, (V) { ~0U, ~0U, ~0U, ~0U, ~0U, ~0U, ~0U, ~0U }, (V) { 0, 1, 8, 3, 4, 5, 9, 7 });
DJ Delorie June 6, 2015, 5:55 a.m. UTC | #2
Sorry, I meant unsigned int.

Patch
diff mbox

Index: gcc.dg/pr64252.c
===================================================================
--- gcc.dg/pr64252.c	(revision 224181)
+++ gcc.dg/pr64252.c	(working copy)
@@ -1,11 +1,11 @@ 
 /* PR target/64252 */
 /* { dg-do run } */
 /* { dg-options "-O2" } */
 
-typedef unsigned int V __attribute__((vector_size (32)));
+typedef unsigned int V __attribute__((vector_size (sizeof(unsigned long) * 8)));
 
 __attribute__((noinline, noclone)) void
 foo (V *a, V *b, V *c, V *d, V *e)
 {
   V t = __builtin_shuffle (*a, *b, *c);
   V v = __builtin_shuffle (t, (V) { ~0U, ~0U, ~0U, ~0U, ~0U, ~0U, ~0U, ~0U }, (V) { 0, 1, 8, 3, 4, 5, 9, 7 });