This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] for pr 32160


Hello,

when predictive commoning creates a temporary variable with complex
type, it needs to mark it with DECL_GIMPLE_REG_P, otherwise we ICE
in verify_ssa (as it is considered to be virtual operand).

Bootstrapped & regtested on x86_64.

Zdenek

	PR tree-optimization/32160
	* tree-predcom.c (predcom_tmp_var): New function.  Mark created
	variable as gimple reg.
	(initialize_root_vars, initialize_root_vars_lm): Use predcom_tmp_var.

	* gfortran.dg/predcom-1.f: New test.

Index: testsuite/gfortran.dg/predcom-1.f
===================================================================
*** testsuite/gfortran.dg/predcom-1.f	(revision 0)
--- testsuite/gfortran.dg/predcom-1.f	(revision 0)
***************
*** 0 ****
--- 1,16 ----
+ ! PR 32160, complex temporary variables were not marked as gimple registers
+ ! { dg-do compile }
+ ! { dg-options "-O3" }
+ 
+       REAL             FUNCTION CLANHT( N, E )
+       INTEGER            N
+       COMPLEX            E( * )
+       INTEGER            I
+       REAL               ANORM
+       INTRINSIC          ABS
+             DO 20 I = 1, N
+                ANORM = ANORM +ABS( E( I ) )+ ABS( E( I-1 ) )
+    20       CONTINUE
+       CLANHT = ANORM
+       RETURN
+       END
Index: tree-predcom.c
===================================================================
*** tree-predcom.c	(revision 125216)
--- tree-predcom.c	(working copy)
*************** mark_virtual_ops_for_renaming_list (tree
*** 1401,1406 ****
--- 1401,1426 ----
      mark_virtual_ops_for_renaming (tsi_stmt (tsi));
  }
  
+ /* Returns a new temporary variable used for the I-th variable carrying
+    value of REF.  The variable's uid is marked in TMP_VARS.  */
+ 
+ static tree
+ predcom_tmp_var (tree ref, unsigned i, bitmap tmp_vars)
+ {
+   tree type = TREE_TYPE (ref);
+   tree var = create_tmp_var (type, get_lsm_tmp_name (ref, i));
+ 
+   /* We never access the components of the temporary variable in predictive
+      commoning.  */
+   if (TREE_CODE (type) == COMPLEX_TYPE
+       || TREE_CODE (type) == VECTOR_TYPE)
+     DECL_GIMPLE_REG_P (var) = 1;
+ 
+   add_referenced_var (var);
+   bitmap_set_bit (tmp_vars, DECL_UID (var));
+   return var;
+ }
+ 
  /* Creates the variables for CHAIN, as well as phi nodes for them and
     initialization on entry to LOOP.  Uids of the newly created
     temporary variables are marked in TMP_VARS.  */
*************** initialize_root_vars (struct loop *loop,
*** 1429,1437 ****
  
    for (i = 0; i < n + (reuse_first ? 0 : 1); i++)
      {
!       var = create_tmp_var (TREE_TYPE (ref), get_lsm_tmp_name (ref, i));
!       add_referenced_var (var);
!       bitmap_set_bit (tmp_vars, DECL_UID (var));
        VEC_quick_push (tree, chain->vars, var);
      }
    if (reuse_first)
--- 1449,1455 ----
  
    for (i = 0; i < n + (reuse_first ? 0 : 1); i++)
      {
!       var = predcom_tmp_var (ref, i, tmp_vars);
        VEC_quick_push (tree, chain->vars, var);
      }
    if (reuse_first)
*************** initialize_root_vars_lm (struct loop *lo
*** 1499,1507 ****
    init = VEC_index (tree, inits, 0);
  
    *vars = VEC_alloc (tree, heap, written ? 2 : 1);
!   var = create_tmp_var (TREE_TYPE (ref), get_lsm_tmp_name (ref, 0));
!   add_referenced_var (var);
!   bitmap_set_bit (tmp_vars, DECL_UID (var));
    VEC_quick_push (tree, *vars, var);
    if (written)
      VEC_quick_push (tree, *vars, VEC_index (tree, *vars, 0));
--- 1517,1523 ----
    init = VEC_index (tree, inits, 0);
  
    *vars = VEC_alloc (tree, heap, written ? 2 : 1);
!   var = predcom_tmp_var (ref, 0, tmp_vars);
    VEC_quick_push (tree, *vars, var);
    if (written)
      VEC_quick_push (tree, *vars, VEC_index (tree, *vars, 0));


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]