@@ -1338,6 +1338,71 @@ all_uses_feed_or_dominated_by_stmt (tree name, gimple *stmt)
return true;
}
+/* Handle
+ _4 = x_3 & 31;
+ if (_4 != 0)
+ goto <bb 6>;
+ else
+ goto <bb 7>;
+ <bb 6>:
+ __builtin_unreachable ();
+ <bb 7>:
+
+ If x_3 has no other immediate uses (checked by caller), var is the
+ x_3 var, we can clear low 5 bits from the non-zero bitmask. */
+
+static void
+maybe_set_nonzero_bits (edge e, tree var)
+{
+ basic_block cond_bb = e->src;
+ gcond *cond = safe_dyn_cast <gcond *> (*gsi_last_bb (cond_bb));
+ tree cst;
+
+ if (cond == NULL
+ || gimple_cond_code (cond) != ((e->flags & EDGE_TRUE_VALUE)
+ ? EQ_EXPR : NE_EXPR)
+ || TREE_CODE (gimple_cond_lhs (cond)) != SSA_NAME
+ || !integer_zerop (gimple_cond_rhs (cond)))
+ return;
+
+ gimple *stmt = SSA_NAME_DEF_STMT (gimple_cond_lhs (cond));
+ if (!is_gimple_assign (stmt)
+ || gimple_assign_rhs_code (stmt) != BIT_AND_EXPR
+ || TREE_CODE (gimple_assign_rhs2 (stmt)) != INTEGER_CST)
+ return;
+ if (gimple_assign_rhs1 (stmt) != var)
+ {
+ gimple *stmt2;
+
+ if (TREE_CODE (gimple_assign_rhs1 (stmt)) != SSA_NAME)
+ return;
+ stmt2 = SSA_NAME_DEF_STMT (gimple_assign_rhs1 (stmt));
+ if (!gimple_assign_cast_p (stmt2)
+ || gimple_assign_rhs1 (stmt2) != var
+ || !CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (stmt2))
+ || (TYPE_PRECISION (TREE_TYPE (gimple_assign_rhs1 (stmt)))
+ != TYPE_PRECISION (TREE_TYPE (var))))
+ return;
+ }
+ cst = gimple_assign_rhs2 (stmt);
+ if (POINTER_TYPE_P (TREE_TYPE (var)))
+ {
+ struct ptr_info_def *pi = SSA_NAME_PTR_INFO (var);
+ if (pi && pi->misalign)
+ return;
+ wide_int w = wi::bit_not (wi::to_wide (cst));
+ unsigned int bits = wi::ctz (w);
+ if (bits == 0 || bits >= HOST_BITS_PER_INT)
+ return;
+ unsigned int align = 1U << bits;
+ if (pi == NULL || pi->align < align)
+ set_ptr_info_alignment (get_ptr_info (var), align, 0);
+ }
+ else
+ set_nonzero_bits (var, wi::bit_and_not (get_nonzero_bits (var),
+ wi::to_wide (cst)));
+}
+
/* Set global ranges that can be determined from the C->M edge:
<bb C>:
@@ -633,71 +633,6 @@ overflow_comparison_p (tree_code code, tree name, tree val, tree *new_cst)
true, new_cst);
}
-/* Handle
- _4 = x_3 & 31;
- if (_4 != 0)
- goto <bb 6>;
- else
- goto <bb 7>;
- <bb 6>:
- __builtin_unreachable ();
- <bb 7>:
-
- If x_3 has no other immediate uses (checked by caller), var is the
- x_3 var, we can clear low 5 bits from the non-zero bitmask. */
-
-void
-maybe_set_nonzero_bits (edge e, tree var)
-{
- basic_block cond_bb = e->src;
- gcond *cond = safe_dyn_cast <gcond *> (*gsi_last_bb (cond_bb));
- tree cst;
-
- if (cond == NULL
- || gimple_cond_code (cond) != ((e->flags & EDGE_TRUE_VALUE)
- ? EQ_EXPR : NE_EXPR)
- || TREE_CODE (gimple_cond_lhs (cond)) != SSA_NAME
- || !integer_zerop (gimple_cond_rhs (cond)))
- return;
-
- gimple *stmt = SSA_NAME_DEF_STMT (gimple_cond_lhs (cond));
- if (!is_gimple_assign (stmt)
- || gimple_assign_rhs_code (stmt) != BIT_AND_EXPR
- || TREE_CODE (gimple_assign_rhs2 (stmt)) != INTEGER_CST)
- return;
- if (gimple_assign_rhs1 (stmt) != var)
- {
- gimple *stmt2;
-
- if (TREE_CODE (gimple_assign_rhs1 (stmt)) != SSA_NAME)
- return;
- stmt2 = SSA_NAME_DEF_STMT (gimple_assign_rhs1 (stmt));
- if (!gimple_assign_cast_p (stmt2)
- || gimple_assign_rhs1 (stmt2) != var
- || !CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (stmt2))
- || (TYPE_PRECISION (TREE_TYPE (gimple_assign_rhs1 (stmt)))
- != TYPE_PRECISION (TREE_TYPE (var))))
- return;
- }
- cst = gimple_assign_rhs2 (stmt);
- if (POINTER_TYPE_P (TREE_TYPE (var)))
- {
- struct ptr_info_def *pi = SSA_NAME_PTR_INFO (var);
- if (pi && pi->misalign)
- return;
- wide_int w = wi::bit_not (wi::to_wide (cst));
- unsigned int bits = wi::ctz (w);
- if (bits == 0 || bits >= HOST_BITS_PER_INT)
- return;
- unsigned int align = 1U << bits;
- if (pi == NULL || pi->align < align)
- set_ptr_info_alignment (get_ptr_info (var), align, 0);
- }
- else
- set_nonzero_bits (var, wi::bit_and_not (get_nonzero_bits (var),
- wi::to_wide (cst)));
-}
-
/* Searches the case label vector VEC for the index *IDX of the CASE_LABEL
that includes the value VAL. The search is restricted to the range
[START_IDX, n - 1] where n is the size of VEC.
@@ -32,6 +32,5 @@ extern bool find_case_label_range (gswitch *, tree, tree, size_t *, size_t *);
extern tree find_case_label_range (gswitch *, const irange *vr);
extern bool find_case_label_index (gswitch *, size_t, tree, size_t *);
extern bool overflow_comparison_p (tree_code, tree, tree, tree *);
-extern void maybe_set_nonzero_bits (edge, tree);
#endif /* GCC_TREE_VRP_H */