[gcc r14-4537] tree-optimization/111751 - support 1024 bit vector constant reinterpretation

Richard Biener rguenth@gcc.gnu.org
Tue Oct 10 12:20:14 GMT 2023


https://gcc.gnu.org/g:70b5c6981fcdff246f90e57e91f3e1667eab2eb3

commit r14-4537-g70b5c6981fcdff246f90e57e91f3e1667eab2eb3
Author: Richard Biener <rguenther@suse.de>
Date:   Tue Oct 10 13:33:34 2023 +0200

    tree-optimization/111751 - support 1024 bit vector constant reinterpretation
    
    The following ups the limit in fold_view_convert_expr to handle
    1024bit vectors as used by GCN and RVV.  It also robustifies
    the handling in visit_reference_op_load to properly give up when
    constants cannot be re-interpreted.
    
            PR tree-optimization/111751
            * fold-const.cc (fold_view_convert_expr): Up the buffer size
            to 128 bytes.
            * tree-ssa-sccvn.cc (visit_reference_op_load): Special case
            constants, giving up when re-interpretation to the target type
            fails.

Diff:
---
 gcc/fold-const.cc     | 4 ++--
 gcc/tree-ssa-sccvn.cc | 2 ++
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc
index 4f8561509ff..82299bb7f1d 100644
--- a/gcc/fold-const.cc
+++ b/gcc/fold-const.cc
@@ -9266,8 +9266,8 @@ fold_view_convert_vector_encoding (tree type, tree expr)
 static tree
 fold_view_convert_expr (tree type, tree expr)
 {
-  /* We support up to 512-bit values (for V8DFmode).  */
-  unsigned char buffer[64];
+  /* We support up to 1024-bit values (for GCN/RISC-V V128QImode).  */
+  unsigned char buffer[128];
   int len;
 
   /* Check that the host and target are sane.  */
diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc
index ce8ae8c6753..0b2c10dcc1a 100644
--- a/gcc/tree-ssa-sccvn.cc
+++ b/gcc/tree-ssa-sccvn.cc
@@ -5751,6 +5751,8 @@ visit_reference_op_load (tree lhs, tree op, gimple *stmt)
 	  && maybe_lt (GET_MODE_PRECISION (TYPE_MODE (TREE_TYPE (result))),
 		       GET_MODE_PRECISION (TYPE_MODE (TREE_TYPE (op)))))
 	result = NULL_TREE;
+      else if (CONSTANT_CLASS_P (result))
+	result = const_unop (VIEW_CONVERT_EXPR, TREE_TYPE (op), result);
       else
 	{
 	  /* We will be setting the value number of lhs to the value number


More information about the Gcc-cvs mailing list