Get rid of some gimple_expr_type uses
authorRichard Biener <rguenther@suse.de>
Fri, 16 Jul 2021 10:02:25 +0000 (12:02 +0200)
committerRichard Biener <rguenther@suse.de>
Fri, 16 Jul 2021 10:52:17 +0000 (12:52 +0200)
This gets rid of a few gimple_expr_type uses.

2021-07-16  Richard Biener  <rguenther@suse.de>

* gimple-fold.c (gimple_fold_stmt_to_constant_1): Use
the type of the LHS.
(gimple_assign_nonnegative_warnv_p): Likewise.
(gimple_call_nonnegative_warnv_p): Likewise.  Return false
if the call has no LHS.
* gimple.c (gimple_could_trap_p_1): Use the type of the LHS.
* tree-eh.c (stmt_could_throw_1_p): Likewise.
* tree-inline.c (insert_init_stmt): Likewise.
* tree-ssa-loop-niter.c (get_val_for): Likewise.
* tree-outof-ssa.c (ssa_is_replaceable_p): Use the type of
the def.
* tree-ssa-sccvn.c (init_vn_nary_op_from_stmt): Take a
gassign *.  Use the type of the lhs.
(vn_nary_op_lookup_stmt): Adjust.
(vn_nary_op_insert_stmt): Likewise.

gcc/gimple-fold.c
gcc/gimple.c
gcc/tree-eh.c
gcc/tree-inline.c
gcc/tree-outof-ssa.c
gcc/tree-ssa-loop-niter.c
gcc/tree-ssa-sccvn.c

index 1401092..a3afe87 100644 (file)
@@ -7507,7 +7507,8 @@ gimple_fold_stmt_to_constant_1 (gimple *stmt, tree (*valueize) (tree),
               tree op1 = (*valueize) (gimple_assign_rhs2 (stmt));
               tree op2 = (*valueize) (gimple_assign_rhs3 (stmt));
               return fold_ternary_loc (loc, subcode,
-                                      gimple_expr_type (stmt), op0, op1, op2);
+                                      TREE_TYPE (gimple_assign_lhs (stmt)),
+                                      op0, op1, op2);
             }
 
           default:
@@ -8901,16 +8902,17 @@ gimple_assign_nonnegative_warnv_p (gimple *stmt, bool *strict_overflow_p,
                                   int depth)
 {
   enum tree_code code = gimple_assign_rhs_code (stmt);
+  tree type = TREE_TYPE (gimple_assign_lhs (stmt));
   switch (get_gimple_rhs_class (code))
     {
     case GIMPLE_UNARY_RHS:
       return tree_unary_nonnegative_warnv_p (gimple_assign_rhs_code (stmt),
-                                            gimple_expr_type (stmt),
+                                            type,
                                             gimple_assign_rhs1 (stmt),
                                             strict_overflow_p, depth);
     case GIMPLE_BINARY_RHS:
       return tree_binary_nonnegative_warnv_p (gimple_assign_rhs_code (stmt),
-                                             gimple_expr_type (stmt),
+                                             type,
                                              gimple_assign_rhs1 (stmt),
                                              gimple_assign_rhs2 (stmt),
                                              strict_overflow_p, depth);
@@ -8938,12 +8940,12 @@ gimple_call_nonnegative_warnv_p (gimple *stmt, bool *strict_overflow_p,
     gimple_call_arg (stmt, 0) : NULL_TREE;
   tree arg1 = gimple_call_num_args (stmt) > 1 ?
     gimple_call_arg (stmt, 1) : NULL_TREE;
-
-  return tree_call_nonnegative_warnv_p (gimple_expr_type (stmt),
-                                       gimple_call_combined_fn (stmt),
-                                       arg0,
-                                       arg1,
-                                       strict_overflow_p, depth);
+  tree lhs = gimple_call_lhs (stmt);
+  return (lhs
+         && tree_call_nonnegative_warnv_p (TREE_TYPE (lhs),
+                                           gimple_call_combined_fn (stmt),
+                                           arg0, arg1,
+                                           strict_overflow_p, depth));
 }
 
 /* Return true if return value of call STMT is known to be non-negative.
index 0690f94..863bc0d 100644 (file)
@@ -2164,12 +2164,12 @@ gimple_could_trap_p_1 (const gimple *s, bool include_mem, bool include_stores)
       if (op == COND_EXPR)
        return tree_could_trap_p (gimple_assign_rhs1 (s));
 
-      /* For comparisons we need to check rhs operand types instead of rhs type
+      /* For comparisons we need to check rhs operand types instead of lhs type
          (which is BOOLEAN_TYPE).  */
       if (TREE_CODE_CLASS (op) == tcc_comparison)
        t = TREE_TYPE (gimple_assign_rhs1 (s));
       else
-       t = gimple_expr_type (s);
+       t = TREE_TYPE (gimple_assign_lhs (s));
 
       if (get_gimple_rhs_class (op) == GIMPLE_BINARY_RHS)
        div = gimple_assign_rhs2 (s);
index 57ce8f0..3a09de9 100644 (file)
@@ -2856,7 +2856,7 @@ stmt_could_throw_1_p (gassign *stmt)
       if (TREE_CODE_CLASS (code) == tcc_comparison)
        t = TREE_TYPE (gimple_assign_rhs1 (stmt));
       else
-       t = gimple_expr_type (stmt);
+       t = TREE_TYPE (gimple_assign_lhs (stmt));
       fp_operation = FLOAT_TYPE_P (t);
       if (fp_operation)
        {
index f605e76..8e6cdd3 100644 (file)
@@ -3398,7 +3398,7 @@ insert_init_stmt (copy_body_data *id, basic_block bb, gimple *init_stmt)
          && gimple_assign_rhs_class (init_stmt) == GIMPLE_UNARY_RHS)
        {
          tree rhs = build1 (gimple_assign_rhs_code (init_stmt),
-                            gimple_expr_type (init_stmt),
+                            TREE_TYPE (gimple_assign_lhs (init_stmt)),
                             gimple_assign_rhs1 (init_stmt));
          rhs = force_gimple_operand_gsi (&si, rhs, true, NULL_TREE, false,
                                          GSI_NEW_STMT);
index b730196..1a133a0 100644 (file)
@@ -87,7 +87,7 @@ ssa_is_replaceable_p (gimple *stmt)
 
   /* Float expressions must go through memory if float-store is on.  */
   if (flag_float_store
-      && FLOAT_TYPE_P (gimple_expr_type (stmt)))
+      && FLOAT_TYPE_P (TREE_TYPE (def)))
     return false;
 
   /* An assignment with a register variable on the RHS is not
index b5add82..6fabf10 100644 (file)
@@ -3018,7 +3018,7 @@ get_val_for (tree x, tree base)
   else if (gimple_assign_rhs_class (stmt) == GIMPLE_UNARY_RHS
           && TREE_CODE (gimple_assign_rhs1 (stmt)) == SSA_NAME)
     return fold_build1 (gimple_assign_rhs_code (stmt),
-                       gimple_expr_type (stmt),
+                       TREE_TYPE (gimple_assign_lhs (stmt)),
                        get_val_for (gimple_assign_rhs1 (stmt), base));
   else if (gimple_assign_rhs_class (stmt) == GIMPLE_BINARY_RHS)
     {
@@ -3031,7 +3031,7 @@ get_val_for (tree x, tree base)
       else
        gcc_unreachable ();
       return fold_build2 (gimple_assign_rhs_code (stmt),
-                         gimple_expr_type (stmt), rhs1, rhs2);
+                         TREE_TYPE (gimple_assign_lhs (stmt)), rhs1, rhs2);
     }
   else
     gcc_unreachable ();
index d6aee2e..7900df9 100644 (file)
@@ -423,7 +423,7 @@ static unsigned int vn_nary_length_from_stmt (gimple *);
 static vn_nary_op_t alloc_vn_nary_op_noinit (unsigned int, obstack *);
 static vn_nary_op_t vn_nary_op_insert_into (vn_nary_op_t,
                                            vn_nary_op_table_type *, bool);
-static void init_vn_nary_op_from_stmt (vn_nary_op_t, gimple *);
+static void init_vn_nary_op_from_stmt (vn_nary_op_t, gassign *);
 static void init_vn_nary_op_from_pieces (vn_nary_op_t, unsigned int,
                                         enum tree_code, tree, tree *);
 static tree vn_lookup_simplify_result (gimple_match_op *);
@@ -2377,7 +2377,7 @@ vn_nary_build_or_lookup_1 (gimple_match_op *res_op, bool insert)
          vno1->length = length;
          vno1->predicated_values = 0;
          vno1->u.result = result;
-         init_vn_nary_op_from_stmt (vno1, new_stmt);
+         init_vn_nary_op_from_stmt (vno1, as_a <gassign *> (new_stmt));
          vn_nary_op_insert_into (vno1, valid_info->nary, true);
          /* Also do not link it into the undo chain.  */
          last_inserted_nary = vno1->next;
@@ -3882,12 +3882,12 @@ vn_nary_length_from_stmt (gimple *stmt)
 /* Initialize VNO from STMT.  */
 
 static void
-init_vn_nary_op_from_stmt (vn_nary_op_t vno, gimple *stmt)
+init_vn_nary_op_from_stmt (vn_nary_op_t vno, gassign *stmt)
 {
   unsigned i;
 
   vno->opcode = gimple_assign_rhs_code (stmt);
-  vno->type = gimple_expr_type (stmt);
+  vno->type = TREE_TYPE (gimple_assign_lhs (stmt));
   switch (vno->opcode)
     {
     case REALPART_EXPR:
@@ -3968,7 +3968,7 @@ vn_nary_op_lookup_stmt (gimple *stmt, vn_nary_op_t *vnresult)
   vn_nary_op_t vno1
     = XALLOCAVAR (struct vn_nary_op_s,
                  sizeof_vn_nary_op (vn_nary_length_from_stmt (stmt)));
-  init_vn_nary_op_from_stmt (vno1, stmt);
+  init_vn_nary_op_from_stmt (vno1, as_a <gassign *> (stmt));
   return vn_nary_op_lookup_1 (vno1, vnresult);
 }
 
@@ -4221,7 +4221,7 @@ vn_nary_op_insert_stmt (gimple *stmt, tree result)
   vn_nary_op_t vno1
     = alloc_vn_nary_op (vn_nary_length_from_stmt (stmt),
                        result, VN_INFO (result)->value_id);
-  init_vn_nary_op_from_stmt (vno1, stmt);
+  init_vn_nary_op_from_stmt (vno1, as_a <gassign *> (stmt));
   return vn_nary_op_insert_into (vno1, valid_info->nary, true);
 }