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

RFA: Consider int and same-size short as equivalent vector components

avr currently shows the following failure:
FAIL: c-c++-common/vector-scalar.c  -Wc++-compat  (test for excess errors)
Excess errors:
.c:9:34: error: invalid operands to binary | (have '__vector(8) int' and 'veci')

The issue is that when we compute the result of an operatiopn of a veci and an
int, we get a __vector(8) int result (int is the same size as short),
yet the typechecking later does not accept the vectors as compatible.
Fixed by relaxing the latter for the case that int and short are the same size.

bootstrapped / regtested on i686-pc-linux-gnu.

OK to apply?
2013-07-17  Joern Rennecke  <>

	* c-common.c (same_scalar_type_ignoring_signedness): Also
	accept short/int as equivalent if they have the same precision.

Index: c-family/c-common.c
--- c-family/c-common.c	(revision 201992)
+++ c-family/c-common.c	(working copy)
@@ -10700,10 +10700,22 @@ same_scalar_type_ignoring_signedness (tr
 	      && (c2 == INTEGER_TYPE || c2 == REAL_TYPE
 		  || c2 == FIXED_POINT_TYPE));
+  t1 = c_common_signed_type (t1);
+  t2 = c_common_signed_type (t2);
   /* Equality works here because c_common_signed_type uses
-  return c_common_signed_type (t1)
-    == c_common_signed_type (t2);
+  if (t1 == t2)
+    return true;
+    return false;
+  /* When short and int are the same size, we promote vectors of short
+     to vectors of int when doing arithmetic with scalars.  Hence,
+     we also have to accept mixing short / int vectors in this case.
+     Example: c-c++-common/vector-scalar.c for target avr.  */
+  if ((t1 == integer_type_node && t2 == short_integer_type_node)
+      || (t2 == integer_type_node && t1 == short_integer_type_node))
+    return true;
+  return false;
 /* Check for missing format attributes on function pointers.  LTYPE is

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