[PATCH] Fix PR54219

2012-08-10 Thread Richard Guenther

This fixes an error I introduced when making the VECTOR_CST representation
changes.

Bootstrap and regtest pending on x86_64-unknown-linux-gnu.

Richard.

2012-08-10  Richard Guenther  rguent...@suse.de

PR middle-end/54219
* fold-const.c (fold_ternary_loc): Do not reverse the mask
when canonicalizing it when folding VEC_PERM_EXPR.

* gcc.dg/torture/vector-shuffle1.c: New testcase.

Index: gcc/fold-const.c
===
*** gcc/fold-const.c(revision 190288)
--- gcc/fold-const.c(working copy)
*** fold_ternary_loc (location_t loc, enum t
*** 14189,14195 
  tree *tsel = XALLOCAVEC (tree, nelts);
  tree eltype = TREE_TYPE (TREE_TYPE (arg2));
  for (i = 0; i  nelts; i++)
!   tsel[i] = build_int_cst (eltype, sel[nelts - i - 1]);
  t = build_vector (TREE_TYPE (arg2), tsel);
  return build3_loc (loc, VEC_PERM_EXPR, type, op0, op1, t);
}
--- 14189,14195 
  tree *tsel = XALLOCAVEC (tree, nelts);
  tree eltype = TREE_TYPE (TREE_TYPE (arg2));
  for (i = 0; i  nelts; i++)
!   tsel[i] = build_int_cst (eltype, sel[i]);
  t = build_vector (TREE_TYPE (arg2), tsel);
  return build3_loc (loc, VEC_PERM_EXPR, type, op0, op1, t);
}
Index: gcc/testsuite/gcc.dg/torture/vector-shuffle1.c
===
*** gcc/testsuite/gcc.dg/torture/vector-shuffle1.c  (revision 0)
--- gcc/testsuite/gcc.dg/torture/vector-shuffle1.c  (working copy)
***
*** 0 
--- 1,20 
+ /* PR54219 */
+ /* { dg-do run } */
+ 
+ extern void abort (void);
+ 
+ typedef int v2si __attribute__((vector_size(2*sizeof(int;
+ 
+ v2si f(v2si x)
+ {
+   /* This requires canonicalization of the mask to { 1, 0 }.  */
+   return __builtin_shuffle(x,x, (v2si) { 5, 0 });
+ }
+ 
+ int main()
+ {
+   v2si y = f((v2si) { 1, 2 });
+   if (y[0] != 2 || y[1] != 1)
+ abort ();
+   return 0;
+ }


Re: [PATCH] Fix PR54219

2012-08-10 Thread Jakub Jelinek
On Fri, Aug 10, 2012 at 01:07:33PM +0200, Richard Guenther wrote:
 This fixes an error I introduced when making the VECTOR_CST representation
 changes.
 
 Bootstrap and regtest pending on x86_64-unknown-linux-gnu.

The test fails on i686-linux and guess many other targets, passing vector
types as parameters/return values is generating various ABI warnings.

The testcase fails/works the same if the vectors are passed through memory.
Ok for trunk?

2012-08-10  Jakub Jelinek  ja...@redhat.com

* gcc.dg/torture/vector-shuffle1.c (f): Pass vectors indirectly
to avoid warnings.

--- gcc/testsuite/gcc.dg/torture/vector-shuffle1.c.jj   2012-08-10 
18:00:26.0 +0200
+++ gcc/testsuite/gcc.dg/torture/vector-shuffle1.c  2012-08-10 
18:03:03.765134911 +0200
@@ -5,15 +5,16 @@ extern void abort (void);
 
 typedef int v2si __attribute__((vector_size(2*sizeof(int;
 
-v2si f(v2si x)
+void f(v2si *x)
 {
   /* This requires canonicalization of the mask to { 1, 0 }.  */
-  return __builtin_shuffle(x,x, (v2si) { 5, 0 });
+  *x = __builtin_shuffle(*x, *x, (v2si) { 5, 0 });
 }
 
 int main()
 {
-  v2si y = f((v2si) { 1, 2 });
+  v2si y = { 1, 2 };
+  f(y);
   if (y[0] != 2 || y[1] != 1)
 abort ();
   return 0;


Jakub


Re: [PATCH] Fix PR54219

2012-08-10 Thread Richard Henderson
On 2012-08-10 09:09, Jakub Jelinek wrote:
   * gcc.dg/torture/vector-shuffle1.c (f): Pass vectors indirectly
   to avoid warnings.

Ok.


r~