This patch changes the type of ipa_parm_adjustment::offset from
HOST_WIDE_INT to poly_int64 and updates uses accordingly.


2017-10-23  Richard Sandiford  <richard.sandif...@linaro.org>
            Alan Hayward  <alan.hayw...@arm.com>
            David Sherwood  <david.sherw...@arm.com>

gcc/
        * ipa-prop.h (ipa_parm_adjustment::offset): Change from
        HOST_WIDE_INT to poly_int64_pod.
        * ipa-prop.c (ipa_modify_call_arguments): Track polynomail
        parameter offsets.

Index: gcc/ipa-prop.h
===================================================================
--- gcc/ipa-prop.h      2017-10-23 17:07:40.959671257 +0100
+++ gcc/ipa-prop.h      2017-10-23 17:16:58.508429306 +0100
@@ -828,7 +828,7 @@ struct ipa_parm_adjustment
 
   /* Offset into the original parameter (for the cases when the new parameter
      is a component of an original one).  */
-  HOST_WIDE_INT offset;
+  poly_int64_pod offset;
 
   /* Zero based index of the original parameter this one is based on.  */
   int base_index;
Index: gcc/ipa-prop.c
===================================================================
--- gcc/ipa-prop.c      2017-10-23 17:07:40.959671257 +0100
+++ gcc/ipa-prop.c      2017-10-23 17:16:58.507429441 +0100
@@ -4302,15 +4302,14 @@ ipa_modify_call_arguments (struct cgraph
             simply taking the address of a reference inside the original
             aggregate.  */
 
-         gcc_checking_assert (adj->offset % BITS_PER_UNIT == 0);
+         poly_int64 byte_offset = exact_div (adj->offset, BITS_PER_UNIT);
          base = gimple_call_arg (stmt, adj->base_index);
          loc = DECL_P (base) ? DECL_SOURCE_LOCATION (base)
                              : EXPR_LOCATION (base);
 
          if (TREE_CODE (base) != ADDR_EXPR
              && POINTER_TYPE_P (TREE_TYPE (base)))
-           off = build_int_cst (adj->alias_ptr_type,
-                                adj->offset / BITS_PER_UNIT);
+           off = build_int_cst (adj->alias_ptr_type, byte_offset);
          else
            {
              HOST_WIDE_INT base_offset;
@@ -4330,8 +4329,7 @@ ipa_modify_call_arguments (struct cgraph
              if (!base)
                {
                  base = build_fold_addr_expr (prev_base);
-                 off = build_int_cst (adj->alias_ptr_type,
-                                      adj->offset / BITS_PER_UNIT);
+                 off = build_int_cst (adj->alias_ptr_type, byte_offset);
                }
              else if (TREE_CODE (base) == MEM_REF)
                {
@@ -4341,8 +4339,7 @@ ipa_modify_call_arguments (struct cgraph
                      deref_align = TYPE_ALIGN (TREE_TYPE (base));
                    }
                  off = build_int_cst (adj->alias_ptr_type,
-                                      base_offset
-                                      + adj->offset / BITS_PER_UNIT);
+                                      base_offset + byte_offset);
                  off = int_const_binop (PLUS_EXPR, TREE_OPERAND (base, 1),
                                         off);
                  base = TREE_OPERAND (base, 0);
@@ -4350,8 +4347,7 @@ ipa_modify_call_arguments (struct cgraph
              else
                {
                  off = build_int_cst (adj->alias_ptr_type,
-                                      base_offset
-                                      + adj->offset / BITS_PER_UNIT);
+                                      base_offset + byte_offset);
                  base = build_fold_addr_expr (base);
                }
            }
@@ -4602,7 +4598,7 @@ ipa_get_adjustment_candidate (tree **exp
       struct ipa_parm_adjustment *adj = &adjustments[i];
 
       if (adj->base == base
-         && (adj->offset == offset || adj->op == IPA_PARM_OP_REMOVE))
+         && (must_eq (adj->offset, offset) || adj->op == IPA_PARM_OP_REMOVE))
        {
          cand = adj;
          break;
@@ -4766,7 +4762,10 @@ ipa_dump_param_adjustments (FILE *file,
       else if (adj->op == IPA_PARM_OP_REMOVE)
        fprintf (file, ", remove_param");
       else
-       fprintf (file, ", offset %li", (long) adj->offset);
+       {
+         fprintf (file, ", offset ");
+         print_dec (adj->offset, file);
+       }
       if (adj->by_ref)
        fprintf (file, ", by_ref");
       print_node_brief (file, ", type: ", adj->type, 0);

Reply via email to