summaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-forwprop.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/tree-ssa-forwprop.c')
-rw-r--r--gcc/tree-ssa-forwprop.c87
1 files changed, 44 insertions, 43 deletions
diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c
index c3e0fac0775..863a3ef18af 100644
--- a/gcc/tree-ssa-forwprop.c
+++ b/gcc/tree-ssa-forwprop.c
@@ -801,9 +801,9 @@ forward_propagate_addr_expr_1 (tree name, tree def_rhs,
if ((def_rhs_base = get_addr_base_and_unit_offset (TREE_OPERAND (def_rhs, 0),
&def_rhs_offset)))
{
- double_int off = mem_ref_offset (lhs);
+ addr_wide_int off = mem_ref_offset (lhs);
tree new_ptr;
- off += double_int::from_shwi (def_rhs_offset);
+ off += def_rhs_offset;
if (TREE_CODE (def_rhs_base) == MEM_REF)
{
off += mem_ref_offset (def_rhs_base);
@@ -813,7 +813,7 @@ forward_propagate_addr_expr_1 (tree name, tree def_rhs,
new_ptr = build_fold_addr_expr (def_rhs_base);
TREE_OPERAND (lhs, 0) = new_ptr;
TREE_OPERAND (lhs, 1)
- = double_int_to_tree (TREE_TYPE (TREE_OPERAND (lhs, 1)), off);
+ = wide_int_to_tree (TREE_TYPE (TREE_OPERAND (lhs, 1)), off);
tidy_after_forward_propagate_addr (use_stmt);
/* Continue propagating into the RHS if this was not the only use. */
if (single_use_p)
@@ -889,9 +889,9 @@ forward_propagate_addr_expr_1 (tree name, tree def_rhs,
if ((def_rhs_base = get_addr_base_and_unit_offset (TREE_OPERAND (def_rhs, 0),
&def_rhs_offset)))
{
- double_int off = mem_ref_offset (rhs);
+ addr_wide_int off = mem_ref_offset (rhs);
tree new_ptr;
- off += double_int::from_shwi (def_rhs_offset);
+ off += def_rhs_offset;
if (TREE_CODE (def_rhs_base) == MEM_REF)
{
off += mem_ref_offset (def_rhs_base);
@@ -901,7 +901,7 @@ forward_propagate_addr_expr_1 (tree name, tree def_rhs,
new_ptr = build_fold_addr_expr (def_rhs_base);
TREE_OPERAND (rhs, 0) = new_ptr;
TREE_OPERAND (rhs, 1)
- = double_int_to_tree (TREE_TYPE (TREE_OPERAND (rhs, 1)), off);
+ = wide_int_to_tree (TREE_TYPE (TREE_OPERAND (rhs, 1)), off);
fold_stmt_inplace (use_stmt_gsi);
tidy_after_forward_propagate_addr (use_stmt);
return res;
@@ -1429,8 +1429,8 @@ constant_pointer_difference (tree p1, tree p2)
{
p = TREE_OPERAND (q, 0);
off = size_binop (PLUS_EXPR, off,
- double_int_to_tree (sizetype,
- mem_ref_offset (q)));
+ wide_int_to_tree (sizetype,
+ mem_ref_offset (q)));
}
else
{
@@ -1512,8 +1512,8 @@ simplify_builtin_call (gimple_stmt_iterator *gsi_p, tree callee2)
char *src_buf;
use_operand_p use_p;
- if (!host_integerp (val2, 0)
- || !host_integerp (len2, 1))
+ if (!tree_fits_shwi_p (val2)
+ || !tree_fits_uhwi_p (len2))
break;
if (is_gimple_call (stmt1))
{
@@ -1532,15 +1532,15 @@ simplify_builtin_call (gimple_stmt_iterator *gsi_p, tree callee2)
src1 = gimple_call_arg (stmt1, 1);
len1 = gimple_call_arg (stmt1, 2);
lhs1 = gimple_call_lhs (stmt1);
- if (!host_integerp (len1, 1))
+ if (!tree_fits_uhwi_p (len1))
break;
str1 = string_constant (src1, &off1);
if (str1 == NULL_TREE)
break;
- if (!host_integerp (off1, 1)
+ if (!tree_fits_uhwi_p (off1)
|| compare_tree_int (off1, TREE_STRING_LENGTH (str1) - 1) > 0
|| compare_tree_int (len1, TREE_STRING_LENGTH (str1)
- - tree_low_cst (off1, 1)) > 0
+ - tree_to_uhwi (off1)) > 0
|| TREE_CODE (TREE_TYPE (str1)) != ARRAY_TYPE
|| TYPE_MODE (TREE_TYPE (TREE_TYPE (str1)))
!= TYPE_MODE (char_type_node))
@@ -1554,7 +1554,7 @@ simplify_builtin_call (gimple_stmt_iterator *gsi_p, tree callee2)
src1 = gimple_assign_rhs1 (stmt1);
if (TREE_CODE (ptr1) != MEM_REF
|| TYPE_MODE (TREE_TYPE (ptr1)) != TYPE_MODE (char_type_node)
- || !host_integerp (src1, 0))
+ || !tree_fits_shwi_p (src1))
break;
ptr1 = build_fold_addr_expr (ptr1);
callee1 = NULL_TREE;
@@ -1578,16 +1578,16 @@ simplify_builtin_call (gimple_stmt_iterator *gsi_p, tree callee2)
/* If the difference between the second and first destination pointer
is not constant, or is bigger than memcpy length, bail out. */
if (diff == NULL
- || !host_integerp (diff, 1)
+ || !tree_fits_uhwi_p (diff)
|| tree_int_cst_lt (len1, diff))
break;
/* Use maximum of difference plus memset length and memcpy length
as the new memcpy length, if it is too big, bail out. */
- src_len = tree_low_cst (diff, 1);
- src_len += tree_low_cst (len2, 1);
- if (src_len < (unsigned HOST_WIDE_INT) tree_low_cst (len1, 1))
- src_len = tree_low_cst (len1, 1);
+ src_len = tree_to_uhwi (diff);
+ src_len += tree_to_uhwi (len2);
+ if (src_len < (unsigned HOST_WIDE_INT) tree_to_uhwi (len1))
+ src_len = tree_to_uhwi (len1);
if (src_len > 1024)
break;
@@ -1613,12 +1613,12 @@ simplify_builtin_call (gimple_stmt_iterator *gsi_p, tree callee2)
src_buf = XALLOCAVEC (char, src_len + 1);
if (callee1)
memcpy (src_buf,
- TREE_STRING_POINTER (str1) + tree_low_cst (off1, 1),
- tree_low_cst (len1, 1));
+ TREE_STRING_POINTER (str1) + tree_to_uhwi (off1),
+ tree_to_uhwi (len1));
else
- src_buf[0] = tree_low_cst (src1, 0);
- memset (src_buf + tree_low_cst (diff, 1),
- tree_low_cst (val2, 0), tree_low_cst (len2, 1));
+ src_buf[0] = tree_to_shwi (src1);
+ memset (src_buf + tree_to_uhwi (diff),
+ tree_to_shwi (val2), tree_to_uhwi (len2));
src_buf[src_len] = '\0';
/* Neither builtin_strncpy_read_str nor builtin_memcpy_read_str
handle embedded '\0's. */
@@ -2302,10 +2302,10 @@ simplify_rotate (gimple_stmt_iterator *gsi)
return false;
/* CNT1 + CNT2 == B case above. */
- if (host_integerp (def_arg2[0], 1)
- && host_integerp (def_arg2[1], 1)
- && (unsigned HOST_WIDE_INT) tree_low_cst (def_arg2[0], 1)
- + tree_low_cst (def_arg2[1], 1) == TYPE_PRECISION (rtype))
+ if (tree_fits_uhwi_p (def_arg2[0])
+ && tree_fits_uhwi_p (def_arg2[1])
+ && (unsigned HOST_WIDE_INT) tree_to_uhwi (def_arg2[0])
+ + tree_to_uhwi (def_arg2[1]) == TYPE_PRECISION (rtype))
rotcnt = def_arg2[0];
else if (TREE_CODE (def_arg2[0]) != SSA_NAME
|| TREE_CODE (def_arg2[1]) != SSA_NAME)
@@ -2339,8 +2339,8 @@ simplify_rotate (gimple_stmt_iterator *gsi)
/* Check for one shift count being Y and the other B - Y,
with optional casts. */
if (cdef_code[i] == MINUS_EXPR
- && host_integerp (cdef_arg1[i], 0)
- && tree_low_cst (cdef_arg1[i], 0) == TYPE_PRECISION (rtype)
+ && tree_fits_shwi_p (cdef_arg1[i])
+ && tree_to_shwi (cdef_arg1[i]) == TYPE_PRECISION (rtype)
&& TREE_CODE (cdef_arg2[i]) == SSA_NAME)
{
tree tem;
@@ -2371,8 +2371,8 @@ simplify_rotate (gimple_stmt_iterator *gsi)
This alternative is safe even for rotation count of 0.
One shift count is Y and the other (-Y) & (B - 1). */
else if (cdef_code[i] == BIT_AND_EXPR
- && host_integerp (cdef_arg2[i], 0)
- && tree_low_cst (cdef_arg2[i], 0)
+ && tree_fits_shwi_p (cdef_arg2[i])
+ && tree_to_shwi (cdef_arg2[i])
== TYPE_PRECISION (rtype) - 1
&& TREE_CODE (cdef_arg1[i]) == SSA_NAME
&& gimple_assign_rhs_code (stmt) == BIT_IOR_EXPR)
@@ -2773,7 +2773,7 @@ associate_pointerplus (gimple_stmt_iterator *gsi)
if (gimple_assign_rhs1 (def_stmt) != ptr)
return false;
- algn = double_int_to_tree (TREE_TYPE (ptr), ~tree_to_double_int (algn));
+ algn = wide_int_to_tree (TREE_TYPE (ptr), ~wide_int (algn));
gimple_assign_set_rhs_with_ops (gsi, BIT_AND_EXPR, ptr, algn);
fold_stmt_inplace (gsi);
update_stmt (stmt);
@@ -2935,8 +2935,9 @@ combine_conversions (gimple_stmt_iterator *gsi)
tree tem;
tem = fold_build2 (BIT_AND_EXPR, inside_type,
defop0,
- double_int_to_tree
- (inside_type, double_int::mask (inter_prec)));
+ wide_int_to_tree
+ (inside_type, wide_int::mask (inter_prec, false,
+ TYPE_PRECISION (inside_type))));
if (!useless_type_conversion_p (type, inside_type))
{
tem = force_gimple_operand_gsi (gsi, tem, true, NULL_TREE, true,
@@ -3020,11 +3021,11 @@ simplify_bitfield_ref (gimple_stmt_iterator *gsi)
if (TREE_TYPE (op) != elem_type)
return false;
- size = TREE_INT_CST_LOW (TYPE_SIZE (elem_type));
- n = TREE_INT_CST_LOW (op1) / size;
+ size = tree_to_hwi (TYPE_SIZE (elem_type));
+ n = tree_to_hwi (op1) / size;
if (n != 1)
return false;
- idx = TREE_INT_CST_LOW (op2) / size;
+ idx = tree_to_hwi (op2) / size;
if (code == VEC_PERM_EXPR)
{
@@ -3034,7 +3035,7 @@ simplify_bitfield_ref (gimple_stmt_iterator *gsi)
if (TREE_CODE (m) != VECTOR_CST)
return false;
nelts = VECTOR_CST_NELTS (m);
- idx = TREE_INT_CST_LOW (VECTOR_CST_ELT (m, idx));
+ idx = tree_to_hwi (VECTOR_CST_ELT (m, idx));
idx %= 2 * nelts;
if (idx < nelts)
{
@@ -3078,7 +3079,7 @@ is_combined_permutation_identity (tree mask1, tree mask2)
{
tree val = VECTOR_CST_ELT (mask, i);
gcc_assert (TREE_CODE (val) == INTEGER_CST);
- j = TREE_INT_CST_LOW (val) & (2 * nelts - 1);
+ j = tree_to_hwi (val) & (2 * nelts - 1);
if (j == i)
maybe_identity2 = false;
else if (j == i + nelts)
@@ -3223,7 +3224,7 @@ simplify_vector_constructor (gimple_stmt_iterator *gsi)
nelts = TYPE_VECTOR_SUBPARTS (type);
elem_type = TREE_TYPE (type);
- elem_size = TREE_INT_CST_LOW (TYPE_SIZE (elem_type));
+ elem_size = tree_to_hwi (TYPE_SIZE (elem_type));
sel = XALLOCAVEC (unsigned char, nelts);
orig = NULL;
@@ -3258,9 +3259,9 @@ simplify_vector_constructor (gimple_stmt_iterator *gsi)
return false;
orig = ref;
}
- if (TREE_INT_CST_LOW (TREE_OPERAND (op1, 1)) != elem_size)
+ if (tree_to_hwi (TREE_OPERAND (op1, 1)) != elem_size)
return false;
- sel[i] = TREE_INT_CST_LOW (TREE_OPERAND (op1, 2)) / elem_size;
+ sel[i] = tree_to_hwi (TREE_OPERAND (op1, 2)) / elem_size;
if (sel[i] != i) maybe_ident = false;
}
if (i < nelts)