]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/112369 - strip_float_extensions and vectors
authorRichard Biener <rguenther@suse.de>
Mon, 6 Nov 2023 07:58:18 +0000 (08:58 +0100)
committerRichard Biener <rguenther@suse.de>
Mon, 6 Nov 2023 08:55:27 +0000 (09:55 +0100)
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.

gcc/testsuite/gcc.dg/pr112369.c [new file with mode: 0644]
gcc/tree.cc

diff --git a/gcc/testsuite/gcc.dg/pr112369.c b/gcc/testsuite/gcc.dg/pr112369.c
new file mode 100644 (file)
index 0000000..677e354
--- /dev/null
@@ -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;
+}
index cfead156ddf311ac22643cd013fb24da22b27e90..9c9b057cd88ccddb423b9383b9df08964620e806 100644 (file)
@@ -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);