View | Details | Return to bug 81503
Collapse All | Expand All

(-)gcc/gimple-ssa-strength-reduction.c (+23 lines)
Lines 2074-2079 replace_mult_candidate (slsr_cand_t c, tree basis_ Link Here
2074
{
2074
{
2075
  tree target_type = TREE_TYPE (gimple_assign_lhs (c->cand_stmt));
2075
  tree target_type = TREE_TYPE (gimple_assign_lhs (c->cand_stmt));
2076
  enum tree_code cand_code = gimple_assign_rhs_code (c->cand_stmt);
2076
  enum tree_code cand_code = gimple_assign_rhs_code (c->cand_stmt);
2077
  unsigned int prec = (POINTER_TYPE_P (target_type)
2078
		       ? TYPE_PRECISION (sizetype)
2079
		       : TYPE_PRECISION (target_type));
2080
  tree maxval = (POINTER_TYPE_P (target_type)
2081
		 ? TYPE_MAX_VALUE (sizetype)
2082
		 : TYPE_MAX_VALUE (target_type));
2083
  /*
2084
  wide_int maxval = wi::max_value (prec, sgn);
2085
  */
2077
2086
2078
  /* It is highly unlikely, but possible, that the resulting
2087
  /* It is highly unlikely, but possible, that the resulting
2079
     bump doesn't fit in a HWI.  Abandon the replacement
2088
     bump doesn't fit in a HWI.  Abandon the replacement
Lines 2082-2087 replace_mult_candidate (slsr_cand_t c, tree basis_ Link Here
2082
     types but allows for safe negation without twisted logic.  */
2091
     types but allows for safe negation without twisted logic.  */
2083
  if (wi::fits_shwi_p (bump)
2092
  if (wi::fits_shwi_p (bump)
2084
      && bump.to_shwi () != HOST_WIDE_INT_MIN
2093
      && bump.to_shwi () != HOST_WIDE_INT_MIN
2094
      /* It is more likely that the bump doesn't fit in the target
2095
	 type, so check whether constraining it to that type changes
2096
	 the value.  For a signed type, the value mustn't change.
2097
         For an unsigned type, the value may only change to a 
2098
         congruent value (for negative bumps).  */
2099
      && (TYPE_UNSIGNED (target_type)
2100
	  || wi::eq_p (bump, wi::ext (bump, prec, SIGNED)))
2101
      && (!TYPE_UNSIGNED (target_type)
2102
	  || wi::eq_p (bump, wi::ext (bump, prec, UNSIGNED))
2103
	  || wi::eq_p (bump + wi::to_widest (maxval) + 1,
2104
		       wi::ext (bump, prec, UNSIGNED)))
2105
	  /*
2106
	  || wi::eq_p (bump + maxval + 1, wi::ext (bump, prec, UNSIGNED)))
2107
	  */
2085
      /* It is not useful to replace casts, copies, negates, or adds of
2108
      /* It is not useful to replace casts, copies, negates, or adds of
2086
	 an SSA name and a constant.  */
2109
	 an SSA name and a constant.  */
2087
      && cand_code != SSA_NAME
2110
      && cand_code != SSA_NAME

Return to bug 81503