From: Richard Biener Date: Mon, 6 Nov 2023 07:58:18 +0000 (+0100) Subject: tree-optimization/112369 - strip_float_extensions and vectors X-Git-Tag: basepoints/gcc-15~4994 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d803438e0c4016aff720fad418377c5b13567063;p=thirdparty%2Fgcc.git tree-optimization/112369 - strip_float_extensions and vectors The following fixes an error in strip_float_extensions when facing vector conversions. PR tree-optimization/112369 * tree.cc (strip_float_extensions): Use element_precision. * gcc.dg/pr112369.c: New testcase. --- diff --git a/gcc/testsuite/gcc.dg/pr112369.c b/gcc/testsuite/gcc.dg/pr112369.c new file mode 100644 index 000000000000..677e3543f54f --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr112369.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ +/* { dg-additional-options "-mavx2" { target avx2 } } */ + +struct GdkRGBA2 { + double a[4]; +}; +struct GdkRGBA3 { + float a[4]; +}; +struct GdkRGBA3 f(struct GdkRGBA2 *color) { + struct GdkRGBA3 t1; + for(int i = 0; i < 4; i++) + t1.a[i] = color->a[i]; + struct GdkRGBA3 t2; + for(int i = 0; i < 4; i++) + { + float tmp = t1.a[i]; + if (__builtin_isnan(tmp)) + t2.a[i] = tmp; + } + return t2; +} diff --git a/gcc/tree.cc b/gcc/tree.cc index cfead156ddf3..9c9b057cd88c 100644 --- a/gcc/tree.cc +++ b/gcc/tree.cc @@ -12138,7 +12138,7 @@ strip_float_extensions (tree exp) if (DECIMAL_FLOAT_TYPE_P (expt) != DECIMAL_FLOAT_TYPE_P (subt)) return exp; - if (TYPE_PRECISION (subt) > TYPE_PRECISION (expt)) + if (element_precision (subt) > element_precision (expt)) return exp; return strip_float_extensions (sub);