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 get_unwidened on casts from vector types (PR middle-end/21850)


Hi!

TYPE_PRECISION has different meaning on vector types and casts from
vectors, being view conversions, certainly should not iterated through,
otherwise we end up with invalid casts.

This is a regression from GCC 3.2.3 apparently.
Ok if testing succeeds, HEAD and 4.0 (once it reopens)?

2005-06-07  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/21850
	* tree.c (get_unwidened): Stop at NOP_EXPR/CONVERT_EXPR that convert
	from vector types.

	* gcc.c-torture/execute/20050607-1.c: New test.

--- gcc/tree.c.jj	2005-06-07 12:30:22.000000000 +0200
+++ gcc/tree.c	2005-06-07 13:49:46.000000000 +0200
@@ -4898,9 +4898,16 @@ get_unwidened (tree op, tree for_type)
   while (TREE_CODE (op) == NOP_EXPR
 	 || TREE_CODE (op) == CONVERT_EXPR)
     {
-      int bitschange
-	= TYPE_PRECISION (TREE_TYPE (op))
-	  - TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (op, 0)));
+      int bitschange;
+
+      /* TYPE_PRECISION on vector types has different meaning
+	 (TYPE_VECTOR_SUBPARTS) and casts from vectors are view conversions,
+	 so avoid them here.  */
+      if (TREE_CODE (TREE_TYPE (TREE_OPERAND (op, 0))) == VECTOR_TYPE)
+	break;
+
+      bitschange = TYPE_PRECISION (TREE_TYPE (op))
+		   - TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (op, 0)));
 
       /* Truncations are many-one so cannot be removed.
 	 Unless we are later going to truncate down even farther.  */
--- gcc/testsuite/gcc.c-torture/execute/20050607-1.c.jj	2005-06-07 13:53:12.000000000 +0200
+++ gcc/testsuite/gcc.c-torture/execute/20050607-1.c	2005-06-07 13:54:31.000000000 +0200
@@ -0,0 +1,16 @@
+/* PR middle-end/21850 */
+
+extern void abort (void);
+
+typedef int V2SI __attribute__ ((vector_size (8)));
+
+int
+main (void)
+{
+#if (__INT_MAX__ == 2147483647) \
+    && (__LONG_LONG_MAX__ == 9223372036854775807LL)
+  if (((int)(long long)(V2SI){ 2, 2 }) != 2)
+    abort ();
+#endif
+  return 0;
+}

	Jakub


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