]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/114921 - _Float16 -> __bf16 isn't noop
authorRichard Biener <rguenther@suse.de>
Thu, 2 May 2024 11:55:15 +0000 (13:55 +0200)
committerRichard Biener <rguenther@suse.de>
Fri, 3 May 2024 06:19:51 +0000 (08:19 +0200)
The vectorizer handles a _Float16 to __bf16 conversion through
vectorizable_assignment, thinking it's a noop.  The following
fixes this by requiring the same vector component mode when
checking for CONVERT_EXPR_CODE_P, being stricter than for
VIEW_CONVERT_EXPR.

PR tree-optimization/114921
* tree-vect-stmts.cc (vectorizable_assignment): Require
same vector component modes for input and output for
CONVERT_EXPR_CODE_P.

gcc/tree-vect-stmts.cc

index f8d8636b139ae8e45a5edf81bd7e5246038075ce..7e571968a59d7f0cc9833ca930f5f2975c8dcd21 100644 (file)
@@ -5955,14 +5955,17 @@ vectorizable_assignment (vec_info *vinfo,
   if (!vectype_in)
     vectype_in = get_vectype_for_scalar_type (vinfo, TREE_TYPE (op), slp_node);
 
-  /* We can handle NOP_EXPR conversions that do not change the number
-     of elements or the vector size.  */
-  if ((CONVERT_EXPR_CODE_P (code)
-       || code == VIEW_CONVERT_EXPR)
-      && (!vectype_in
-         || maybe_ne (TYPE_VECTOR_SUBPARTS (vectype_in), nunits)
-         || maybe_ne (GET_MODE_SIZE (TYPE_MODE (vectype)),
-                      GET_MODE_SIZE (TYPE_MODE (vectype_in)))))
+  /* We can handle VIEW_CONVERT conversions that do not change the number
+     of elements or the vector size or other conversions when the component
+     mode keeps the same.  */
+  if (!vectype_in
+      || maybe_ne (TYPE_VECTOR_SUBPARTS (vectype_in), nunits)
+      || (code == VIEW_CONVERT_EXPR
+         && maybe_ne (GET_MODE_SIZE (TYPE_MODE (vectype)),
+                      GET_MODE_SIZE (TYPE_MODE (vectype_in))))
+      || (CONVERT_EXPR_CODE_P (code)
+         && (TYPE_MODE (TREE_TYPE (vectype))
+             != TYPE_MODE (TREE_TYPE (vectype_in)))))
     return false;
 
   if (VECTOR_BOOLEAN_TYPE_P (vectype) != VECTOR_BOOLEAN_TYPE_P (vectype_in))