Patch for stricter implicit conversions between vectors

Mark Shinwell shinwell@codesourcery.com
Tue Nov 14 12:20:00 GMT 2006


This patch is an implementation of the strategy decided in the
thread starting at http://gcc.gnu.org/ml/gcc/2006-10/msg00682.html.
It also includes the increased checking discussed in the thread starting
at http://gcc.gnu.org/ml/gcc/2006-10/msg00235.html.

It does the following things:

- Disallows implicit conversions between generic vectors with differing
   numbers of subparts.

- Disallows implicit conversions between generic vectors with differing
   element types, even if implicit conversions exist between those element
   types.

- Informs the user of the flag mentioned in the next point when an error
   is diagnosed due to either of the two previous points.  Such an
   informative message is only emitted on the first occasion of any
   such type-checking violation per compilation.

- Adds a new flag -flax-vector-conversions to suppress the extra checking
   in the first two points above.

- Modifies the x86 intrinsic implementation so that char_type_node is used
   for V*QI vectors (to correspond to mmintrin.h) to prevent typechecking
   errors.

- Modifies the Altivec intrinsic implementation to prevent similar errors
   (which were occurring especially from built-in functions that were supposed
   to be returning things such as "vector bool int" as "vector signed int",
   or similar).

- Fixes up testcases that violated either of the first two points in this
   list.

I believe that there are no regressions on either i686-pc-linux-gnu or
powerpc64-unknown-linux-gnu with C and C++ enabled; I am going to perform
final full bootstraps of all default languages on these platforms before
this is committed.  First, however, I would like to ask if anyone has any
comments, or thinks the attached is OK outright?  (In particular I'd
appreciate it if someone could cast a careful eye over the modifications
to the MMX and AltiVec parts, since I am far from an expert on those areas.)

Thanks,
Mark


--


2006-11-14  Mark Shinwell  <shinwell@codesourcery.com>

	gcc/
	* c.opt: Add -flax-vector-conversions.
	* c-typeck.c (convert_for_assignment): Pass flag to
	vector_types_convertible_p to allow emission of note.
	(digest_init): Likewise.
	* c-opts.c: Handle -flax-vector-conversions.
	* c-common.c (flag_lax_vector_conversions): New.
	(vector_types_convertible_p): Unless -flax-vector conversions
	has been passed, disallow conversions between vectors with
	differing numbers of subparts and/or element types.  If such
	a conversion is disallowed, possibly emit a note on the first
	occasion only to inform the user of -flax-vector-conversions.
	The new last argument specifies this.
	* c-common.h (flag_lax_vector_conversions): New.
	(vector_types_convertible_p): Add extra argument.
	* config/i386/i386.c (ix86_init_mmx_sse_builtins): Use
	char_type_node for V*QI type vectors.
	* config/rs6000/rs6000-c.c (altivec_overloaded_builtins):
	Update to satisfy new typechecking rules.
	* config/rs6000/altivec.h (vec_vcmpequb, vec_vcmpequh,
	vec_vcmpequw, vec_cmple): Likewise.

	gcc/cp/
	* call.c (standard_conversion): Pass flag to
	vector_types_convertible_p to disallow emission of note.
	* typeck.c (convert_for_assignment): Pass flag to
	vector_types_convertible_p to allow emission of note.
	(ptr_reasonably_similar): Pass flag to vector_types_convertible_p
	to disallow emission of note.

	gcc/testsuite/
	* gcc.target/i386/20020531-1.c: Use "char" not "unsigned char"
	in __v8qi typedef.
	* gcc.target/powerpc/altivec-vec-merge.c (foo): Add casts.
	* gcc.dg/simd-1.c: Update dg-error directives to reflect new
	compiler behaviour.
	* gcc.dg/simd-5.c: Likewise.
	* gcc.dg/simd-6.c: Likewise.
	* g++.dg/conversion/simd1.C: Likewise.
	* g++.dg/conversion/simd3.C: Likewise.
	* g++.dg/ext/attribute-test-2.C (data): Add "vs" member.
	(main): Use it.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: vector-tightening.patch
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20061114/a1806c04/attachment.ksh>


More information about the Gcc-patches mailing list