public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-5625] middle-end/112622 - convert and vector-to-float
@ 2023-11-20 14:01 Richard Biener
0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2023-11-20 14:01 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:b7a1b89e60c4b492f85b47e02c12b01dd8a6e28b
commit r14-5625-gb7a1b89e60c4b492f85b47e02c12b01dd8a6e28b
Author: Richard Biener <rguenther@suse.de>
Date: Mon Nov 20 11:29:59 2023 +0100
middle-end/112622 - convert and vector-to-float
The following avoids ICEing when trying to convert a vector to
a scalar float.
PR middle-end/112622
* convert.cc (convert_to_real_1): Use element_precision
where a vector type might appear. Provide specific
diagnostic for unexpected vector argument.
* gcc.dg/pr112622.c: New testcase.
* gcc.dg/simd-2.c: Adjust.
* gcc.target/i386/vect-bfloat16-typecheck_1.c: Likewise.
* gcc.target/i386/vect-bfloat16-typecheck_2.c: Likewise.
Diff:
---
gcc/convert.cc | 6 +++++-
gcc/testsuite/gcc.dg/pr112622.c | 5 +++++
gcc/testsuite/gcc.dg/simd-2.c | 4 ++--
gcc/testsuite/gcc.target/i386/vect-bfloat16-typecheck_1.c | 8 ++++----
gcc/testsuite/gcc.target/i386/vect-bfloat16-typecheck_2.c | 8 ++++----
5 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/gcc/convert.cc b/gcc/convert.cc
index ac6af7026a7..46c8bcb31f8 100644
--- a/gcc/convert.cc
+++ b/gcc/convert.cc
@@ -292,7 +292,7 @@ convert_to_real_1 (tree type, tree expr, bool fold_p)
case NEGATE_EXPR:
if (!flag_rounding_math
&& FLOAT_TYPE_P (itype)
- && TYPE_PRECISION (type) < TYPE_PRECISION (itype))
+ && element_precision (type) < element_precision (itype))
{
tree arg = convert_to_real_1 (type, TREE_OPERAND (expr, 0),
fold_p);
@@ -334,6 +334,10 @@ convert_to_real_1 (tree type, tree expr, bool fold_p)
error ("pointer value used where a floating-point was expected");
return error_mark_node;
+ case VECTOR_TYPE:
+ error ("vector value used where a floating-point was expected");
+ return error_mark_node;
+
default:
error ("aggregate value used where a floating-point was expected");
return error_mark_node;
diff --git a/gcc/testsuite/gcc.dg/pr112622.c b/gcc/testsuite/gcc.dg/pr112622.c
new file mode 100644
index 00000000000..c73587ced99
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr112622.c
@@ -0,0 +1,5 @@
+/* { dg-do compile } */
+
+typedef __attribute__((__vector_size__(4))) float V;
+
+V v = (float)-v; /* { dg-error "vector value used" } */
diff --git a/gcc/testsuite/gcc.dg/simd-2.c b/gcc/testsuite/gcc.dg/simd-2.c
index d24e076218d..411bb49a5e1 100644
--- a/gcc/testsuite/gcc.dg/simd-2.c
+++ b/gcc/testsuite/gcc.dg/simd-2.c
@@ -33,10 +33,10 @@ hanneke ()
foo = a; /* { dg-error "incompatible types when assigning" } */
/* Casted assignment between scalar and SIMD of same size. */
- foo = (typeof (foo)) foo2; /* { dg-error "aggregate value used where a floating-point was expected" } */
+ foo = (typeof (foo)) foo2; /* { dg-error "vector value used where a floating-point was expected" } */
/* Casted assignment between scalar and SIMD of different size. */
- foo1 = (typeof (foo1)) foo2; /* { dg-error "aggregate value used where a floating-point was expected" } */
+ foo1 = (typeof (foo1)) foo2; /* { dg-error "vector value used where a floating-point was expected" } */
/* Operators on compatible SIMD types. */
a += b + b;
diff --git a/gcc/testsuite/gcc.target/i386/vect-bfloat16-typecheck_1.c b/gcc/testsuite/gcc.target/i386/vect-bfloat16-typecheck_1.c
index 8bc3f4a7b8f..5d19dcb7b6d 100644
--- a/gcc/testsuite/gcc.target/i386/vect-bfloat16-typecheck_1.c
+++ b/gcc/testsuite/gcc.target/i386/vect-bfloat16-typecheck_1.c
@@ -123,12 +123,12 @@ __m128bf16 footest (__m128bf16 vector0)
(void) glob_bfloat_vec;
(__m128bf16) glob_bfloat_vec;
- (__bf16) glob_bfloat_vec; /* { dg-error {aggregate value used where a floating-point was expected} } */
+ (__bf16) glob_bfloat_vec; /* { dg-error {vector value used where a floating-point was expected} } */
(short) glob_bfloat_vec; /* { dg-error {cannot convert a vector of type '__m128bf16' {aka '__vector\(8\) __bf16'} to type 'short int' which has different size} } */
(int) glob_bfloat_vec; /* { dg-error {cannot convert a vector of type '__m128bf16' {aka '__vector\(8\) __bf16'} to type 'int' which has different size} } */
- (_Float16) glob_bfloat_vec; /* { dg-error {aggregate value used where a floating-point was expected} } */
- (float) glob_bfloat_vec; /* { dg-error {aggregate value used where a floating-point was expected} } */
- (double) glob_bfloat_vec; /* { dg-error {aggregate value used where a floating-point was expected} } */
+ (_Float16) glob_bfloat_vec; /* { dg-error {vector value used where a floating-point was expected} } */
+ (float) glob_bfloat_vec; /* { dg-error {vector value used where a floating-point was expected} } */
+ (double) glob_bfloat_vec; /* { dg-error {vector value used where a floating-point was expected} } */
(__v8si) glob_bfloat_vec; /* { dg-error {cannot convert a value of type '__m128bf16' {aka '__vector\(8\) __bf16'} to vector type '__vector\(8\) int' which has different size} } */
(__m256) glob_bfloat_vec; /* { dg-error {cannot convert a value of type '__m128bf16' {aka '__vector\(8\) __bf16'} to vector type '__vector\(8\) float' which has different size} } */
diff --git a/gcc/testsuite/gcc.target/i386/vect-bfloat16-typecheck_2.c b/gcc/testsuite/gcc.target/i386/vect-bfloat16-typecheck_2.c
index 2a8a535daae..d4e6fc8cd23 100644
--- a/gcc/testsuite/gcc.target/i386/vect-bfloat16-typecheck_2.c
+++ b/gcc/testsuite/gcc.target/i386/vect-bfloat16-typecheck_2.c
@@ -116,12 +116,12 @@ __m256bf16 footest (__m256bf16 vector0)
(void) glob_bfloat_vec;
(__m256bf16) glob_bfloat_vec;
- (__bf16) glob_bfloat_vec; /* { dg-error {aggregate value used where a floating-point was expected} } */
+ (__bf16) glob_bfloat_vec; /* { dg-error {vector value used where a floating-point was expected} } */
(short) glob_bfloat_vec; /* { dg-error {cannot convert a vector of type '__m256bf16' {aka '__vector\(16\) __bf16'} to type 'short int' which has different size} } */
(int) glob_bfloat_vec; /* { dg-error {cannot convert a vector of type '__m256bf16' {aka '__vector\(16\) __bf16'} to type 'int' which has different size} } */
- (_Float16) glob_bfloat_vec; /* { dg-error {aggregate value used where a floating-point was expected} } */
- (float) glob_bfloat_vec; /* { dg-error {aggregate value used where a floating-point was expected} } */
- (double) glob_bfloat_vec; /* { dg-error {aggregate value used where a floating-point was expected} } */
+ (_Float16) glob_bfloat_vec; /* { dg-error {vector value used where a floating-point was expected} } */
+ (float) glob_bfloat_vec; /* { dg-error {vector value used where a floating-point was expected} } */
+ (double) glob_bfloat_vec; /* { dg-error {vector value used where a floating-point was expected} } */
(__v8si) glob_bfloat_vec;
(__m256) glob_bfloat_vec;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-11-20 14:01 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-20 14:01 [gcc r14-5625] middle-end/112622 - convert and vector-to-float Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).