This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] Use zero for step of invariants


Hello,

currently, loop optimizer uses NULL_TREE as step of loop invariants when
they are represented as induction variables, instead of the more
consistent and easier to work with choice -- zero in the appropriate
type.

The reasons for this are purely historical -- when I wrote ivopts & # of
iterations analysis, integer constants were not shared, so this used to
save some memory.

This patch makes us use zero for the step of invariants instead.  It
also removes the last remnants of zero_p and nonzero_p (the
null_or_integer_zerop and nonnull_and_integer_nonzerop functions that
I temporarily introduced in my previous patch).

Bootstrapped & regtested on i686 and x86_64, commited.

Zdenek

	* tree-ssa-loop-niter.c (number_of_iterations_lt_to_ne,
	assert_no_overflow_lt, assert_loop_rolls_lt,
	number_of_iterations_lt, number_of_iterations_le,
	number_of_iterations_cond, number_of_iterations_exit):
	Use integer_zerop/integer_nonzerop instead of
	null_or_integer_zerop/nonnull_and_integer_nonzerop.
	* tree.h (null_or_integer_zerop, nonnull_and_integer_nonzerop):
	Removed.
	* tree-scalar-evolution.c (simple_iv): Return zero for step of
	an invariant.
	* tree-ssa-loop-ivopts.c (alloc_iv): Do not set step of invariants
	to zero.
	(get_iv): Return NULL for non-scalar types.  Use zero as a step
	of an invariant.
	(determine_biv_step, find_interesting_uses_op,
	find_interesting_uses_cond, find_interesting_uses_stmt,
	add_old_ivs_candidates, determine_use_iv_cost_condition,
	rewrite_use_compare, remove_unused_ivs):
	Use integer_zerop instead of null_or_integer_zerop.
	(struct ifs_ivopts_data): Replace step_p field with step field.
	(idx_find_step): Use zero as a step of an invariant.  Modify
	step instead of *step_p.
	(find_interesting_uses_address): Use zero as a step of an invariant.
	Use integer_zerop instead of null_or_integer_zerop.
	(find_interesting_uses_outside): Call find_interesting_uses_op only
	for phi nodes for real operands.
	(add_candidate_1): Expect step to be non-NULL.
	* tree-ssa-loop-prefetch.c (idx_analyze_ref): Expect step to be
	non-NULL.

Index: tree-ssa-loop-niter.c
===================================================================
*** tree-ssa-loop-niter.c	(revision 120156)
--- tree-ssa-loop-niter.c	(working copy)
*************** number_of_iterations_lt_to_ne (tree type
*** 193,199 ****
      mod = fold_build2 (MINUS_EXPR, niter_type, step, mod);
    tmod = fold_convert (type, mod);
  
!   if (nonnull_and_integer_nonzerop (iv0->step))
      {
        /* The final value of the iv is iv1->base + MOD, assuming that this
  	 computation does not overflow, and that
--- 193,199 ----
      mod = fold_build2 (MINUS_EXPR, niter_type, step, mod);
    tmod = fold_convert (type, mod);
  
!   if (integer_nonzerop (iv0->step))
      {
        /* The final value of the iv is iv1->base + MOD, assuming that this
  	 computation does not overflow, and that
*************** assert_no_overflow_lt (tree type, affine
*** 256,262 ****
    tree bound, d, assumption, diff;
    tree niter_type = TREE_TYPE (step);
  
!   if (nonnull_and_integer_nonzerop (iv0->step))
      {
        /* for (i = iv0->base; i < iv1->base; i += iv0->step) */
        if (iv0->no_overflow)
--- 256,262 ----
    tree bound, d, assumption, diff;
    tree niter_type = TREE_TYPE (step);
  
!   if (integer_nonzerop (iv0->step))
      {
        /* for (i = iv0->base; i < iv1->base; i += iv0->step) */
        if (iv0->no_overflow)
*************** assert_loop_rolls_lt (tree type, affine_
*** 324,330 ****
    tree assumption = boolean_true_node, bound, diff;
    tree mbz, mbzl, mbzr;
  
!   if (nonnull_and_integer_nonzerop (iv0->step))
      {
        diff = fold_build2 (MINUS_EXPR, type,
  			  iv0->step, build_int_cst (type, 1));
--- 324,330 ----
    tree assumption = boolean_true_node, bound, diff;
    tree mbz, mbzl, mbzr;
  
!   if (integer_nonzerop (iv0->step))
      {
        diff = fold_build2 (MINUS_EXPR, type,
  			  iv0->step, build_int_cst (type, 1));
*************** number_of_iterations_lt (tree type, affi
*** 384,390 ****
    tree niter_type = unsigned_type_for (type);
    tree delta, step, s;
  
!   if (nonnull_and_integer_nonzerop (iv0->step))
      {
        niter->control = *iv0;
        niter->cmp = LT_EXPR;
--- 384,390 ----
    tree niter_type = unsigned_type_for (type);
    tree delta, step, s;
  
!   if (integer_nonzerop (iv0->step))
      {
        niter->control = *iv0;
        niter->cmp = LT_EXPR;
*************** number_of_iterations_lt (tree type, affi
*** 402,411 ****
  		       fold_convert (niter_type, iv0->base));
  
    /* First handle the special case that the step is +-1.  */
!   if ((iv0->step && integer_onep (iv0->step)
!        && null_or_integer_zerop (iv1->step))
!       || (iv1->step && integer_all_onesp (iv1->step)
! 	  && null_or_integer_zerop (iv0->step)))
      {
        /* for (i = iv0->base; i < iv1->base; i++)
  
--- 402,409 ----
  		       fold_convert (niter_type, iv0->base));
  
    /* First handle the special case that the step is +-1.  */
!   if ((integer_onep (iv0->step) && integer_zerop (iv1->step))
!       || (integer_all_onesp (iv1->step) && integer_zerop (iv0->step)))
      {
        /* for (i = iv0->base; i < iv1->base; i++)
  
*************** number_of_iterations_lt (tree type, affi
*** 421,427 ****
        return true;
      }
  
!   if (nonnull_and_integer_nonzerop (iv0->step))
      step = fold_convert (niter_type, iv0->step);
    else
      step = fold_convert (niter_type,
--- 419,425 ----
        return true;
      }
  
!   if (integer_nonzerop (iv0->step))
      step = fold_convert (niter_type, iv0->step);
    else
      step = fold_convert (niter_type,
*************** number_of_iterations_le (tree type, affi
*** 479,485 ****
  
    if (!never_infinite)
      {
!       if (nonnull_and_integer_nonzerop (iv0->step))
  	assumption = fold_build2 (NE_EXPR, boolean_type_node,
  				  iv1->base, TYPE_MAX_VALUE (type));
        else
--- 477,483 ----
  
    if (!never_infinite)
      {
!       if (integer_nonzerop (iv0->step))
  	assumption = fold_build2 (NE_EXPR, boolean_type_node,
  				  iv1->base, TYPE_MAX_VALUE (type));
        else
*************** number_of_iterations_le (tree type, affi
*** 493,499 ****
  					  niter->assumptions, assumption);
      }
  
!   if (nonnull_and_integer_nonzerop (iv0->step))
      iv1->base = fold_build2 (PLUS_EXPR, type,
  			     iv1->base, build_int_cst (type, 1));
    else
--- 491,497 ----
  					  niter->assumptions, assumption);
      }
  
!   if (integer_nonzerop (iv0->step))
      iv1->base = fold_build2 (PLUS_EXPR, type,
  			     iv1->base, build_int_cst (type, 1));
    else
*************** number_of_iterations_cond (tree type, af
*** 542,548 ****
    /* Make < comparison from > ones, and for NE_EXPR comparisons, ensure that
       the control variable is on lhs.  */
    if (code == GE_EXPR || code == GT_EXPR
!       || (code == NE_EXPR && null_or_integer_zerop (iv0->step)))
      {
        SWAP (iv0, iv1);
        code = swap_tree_comparison (code);
--- 540,546 ----
    /* Make < comparison from > ones, and for NE_EXPR comparisons, ensure that
       the control variable is on lhs.  */
    if (code == GE_EXPR || code == GT_EXPR
!       || (code == NE_EXPR && integer_zerop (iv0->step)))
      {
        SWAP (iv0, iv1);
        code = swap_tree_comparison (code);
*************** number_of_iterations_cond (tree type, af
*** 578,586 ****
  
    /* If the control induction variable does not overflow, the loop obviously
       cannot be infinite.  */
!   if (!null_or_integer_zerop (iv0->step) && iv0->no_overflow)
      never_infinite = true;
!   else if (!null_or_integer_zerop (iv1->step) && iv1->no_overflow)
      never_infinite = true;
    else
      never_infinite = false;
--- 576,584 ----
  
    /* If the control induction variable does not overflow, the loop obviously
       cannot be infinite.  */
!   if (!integer_zerop (iv0->step) && iv0->no_overflow)
      never_infinite = true;
!   else if (!integer_zerop (iv1->step) && iv1->no_overflow)
      never_infinite = true;
    else
      never_infinite = false;
*************** number_of_iterations_cond (tree type, af
*** 588,594 ****
    /* We can handle the case when neither of the sides of the comparison is
       invariant, provided that the test is NE_EXPR.  This rarely occurs in
       practice, but it is simple enough to manage.  */
!   if (!null_or_integer_zerop (iv0->step) && !null_or_integer_zerop (iv1->step))
      {
        if (code != NE_EXPR)
  	return false;
--- 586,592 ----
    /* We can handle the case when neither of the sides of the comparison is
       invariant, provided that the test is NE_EXPR.  This rarely occurs in
       practice, but it is simple enough to manage.  */
!   if (!integer_zerop (iv0->step) && !integer_zerop (iv1->step))
      {
        if (code != NE_EXPR)
  	return false;
*************** number_of_iterations_cond (tree type, af
*** 596,609 ****
        iv0->step = fold_binary_to_constant (MINUS_EXPR, type,
  					   iv0->step, iv1->step);
        iv0->no_overflow = false;
!       iv1->step = NULL_TREE;
        iv1->no_overflow = true;
      }
  
    /* If the result of the comparison is a constant,  the loop is weird.  More
       precise handling would be possible, but the situation is not common enough
       to waste time on it.  */
!   if (null_or_integer_zerop (iv0->step) && null_or_integer_zerop (iv1->step))
      return false;
  
    /* Ignore loops of while (i-- < 10) type.  */
--- 594,607 ----
        iv0->step = fold_binary_to_constant (MINUS_EXPR, type,
  					   iv0->step, iv1->step);
        iv0->no_overflow = false;
!       iv1->step = build_int_cst (type, 0);
        iv1->no_overflow = true;
      }
  
    /* If the result of the comparison is a constant,  the loop is weird.  More
       precise handling would be possible, but the situation is not common enough
       to waste time on it.  */
!   if (integer_zerop (iv0->step) && integer_zerop (iv1->step))
      return false;
  
    /* Ignore loops of while (i-- < 10) type.  */
*************** number_of_iterations_cond (tree type, af
*** 612,618 ****
        if (iv0->step && tree_int_cst_sign_bit (iv0->step))
  	return false;
  
!       if (!null_or_integer_zerop (iv1->step) && !tree_int_cst_sign_bit (iv1->step))
  	return false;
      }
  
--- 610,616 ----
        if (iv0->step && tree_int_cst_sign_bit (iv0->step))
  	return false;
  
!       if (!integer_zerop (iv1->step) && !tree_int_cst_sign_bit (iv1->step))
  	return false;
      }
  
*************** number_of_iterations_cond (tree type, af
*** 628,634 ****
    switch (code)
      {
      case NE_EXPR:
!       gcc_assert (null_or_integer_zerop (iv1->step));
        return number_of_iterations_ne (type, iv0, iv1->base, niter, never_infinite);
      case LT_EXPR:
        return number_of_iterations_lt (type, iv0, iv1, niter, never_infinite);
--- 626,632 ----
    switch (code)
      {
      case NE_EXPR:
!       gcc_assert (integer_zerop (iv1->step));
        return number_of_iterations_ne (type, iv0, iv1->base, niter, never_infinite);
      case LT_EXPR:
        return number_of_iterations_lt (type, iv0, iv1, niter, never_infinite);
*************** number_of_iterations_exit (struct loop *
*** 1099,1109 ****
    
        /* We can provide a more specific warning if one of the operator is
  	 constant and the other advances by +1 or -1.  */
!       if (!null_or_integer_zerop (iv1.step)
! 	  ? (null_or_integer_zerop (iv0.step)
  	     && (integer_onep (iv1.step) || integer_all_onesp (iv1.step)))
! 	  : (iv0.step
! 	     && (integer_onep (iv0.step) || integer_all_onesp (iv0.step))))
          wording =
            flag_unsafe_loop_optimizations
            ? N_("assuming that the loop is not infinite")
--- 1097,1106 ----
    
        /* We can provide a more specific warning if one of the operator is
  	 constant and the other advances by +1 or -1.  */
!       if (!integer_zerop (iv1.step)
! 	  ? (integer_zerop (iv0.step)
  	     && (integer_onep (iv1.step) || integer_all_onesp (iv1.step)))
! 	  : (integer_onep (iv0.step) || integer_all_onesp (iv0.step)))
          wording =
            flag_unsafe_loop_optimizations
            ? N_("assuming that the loop is not infinite")
Index: tree.h
===================================================================
*** tree.h	(revision 120156)
--- tree.h	(working copy)
*************** extern int integer_pow2p (tree);
*** 4075,4096 ****
  
  extern int integer_nonzerop (tree);
  
- /* Returns true if X is either NULL or zero.  */
- 
- static inline bool
- null_or_integer_zerop (tree x)
- {
-   return x == NULL_TREE || integer_zerop (x);
- }
- 
- /* Returns true if X is non-NULL and non-zero.  */
- 
- static inline bool
- nonnull_and_integer_nonzerop (tree x)
- {
-   return x != NULL_TREE && integer_nonzerop (x);
- }
- 
  extern bool cst_and_fits_in_hwi (tree);
  extern tree num_ending_zeros (tree);
  
--- 4075,4080 ----
Index: tree-scalar-evolution.c
===================================================================
*** tree-scalar-evolution.c	(revision 120156)
--- tree-scalar-evolution.c	(working copy)
*************** simple_iv (struct loop *loop, tree stmt,
*** 2813,2818 ****
--- 2813,2819 ----
        && !chrec_contains_symbols_defined_in_loop (ev, loop->num))
      {
        iv->base = ev;
+       iv->step = build_int_cst (TREE_TYPE (ev), 0);
        iv->no_overflow = true;
        return true;
      }
Index: tree-ssa-loop-ivopts.c
===================================================================
*** tree-ssa-loop-ivopts.c	(revision 120156)
--- tree-ssa-loop-ivopts.c	(working copy)
*************** static struct iv *
*** 840,848 ****
  alloc_iv (tree base, tree step)
  {
    struct iv *iv = XCNEW (struct iv);
! 
!   if (step && integer_zerop (step))
!     step = NULL_TREE;
  
    iv->base = base;
    iv->base_object = determine_base_object (base);
--- 840,846 ----
  alloc_iv (tree base, tree step)
  {
    struct iv *iv = XCNEW (struct iv);
!   gcc_assert (step != NULL_TREE);
  
    iv->base = base;
    iv->base_object = determine_base_object (base);
*************** static struct iv *
*** 875,888 ****
  get_iv (struct ivopts_data *data, tree var)
  {
    basic_block bb;
!   
    if (!name_info (data, var)->iv)
      {
        bb = bb_for_stmt (SSA_NAME_DEF_STMT (var));
  
        if (!bb
  	  || !flow_bb_inside_loop_p (data->current_loop, bb))
! 	set_iv (data, var, var, NULL_TREE);
      }
  
    return name_info (data, var)->iv;
--- 873,891 ----
  get_iv (struct ivopts_data *data, tree var)
  {
    basic_block bb;
!   tree type = TREE_TYPE (var);
! 
!   if (!POINTER_TYPE_P (type)
!       && !INTEGRAL_TYPE_P (type))
!     return NULL;
! 
    if (!name_info (data, var)->iv)
      {
        bb = bb_for_stmt (SSA_NAME_DEF_STMT (var));
  
        if (!bb
  	  || !flow_bb_inside_loop_p (data->current_loop, bb))
! 	set_iv (data, var, var, build_int_cst (type, 0));
      }
  
    return name_info (data, var)->iv;
*************** determine_biv_step (tree phi)
*** 904,910 ****
    if (!simple_iv (loop, phi, name, &iv, true))
      return NULL_TREE;
  
!   return (null_or_integer_zerop (iv.step) ? NULL_TREE : iv.step);
  }
  
  /* Finds basic ivs.  */
--- 907,913 ----
    if (!simple_iv (loop, phi, name, &iv, true))
      return NULL_TREE;
  
!   return integer_zerop (iv.step) ? NULL_TREE : iv.step;
  }
  
  /* Finds basic ivs.  */
*************** find_interesting_uses_op (struct ivopts_
*** 1160,1166 ****
        return use;
      }
  
!   if (null_or_integer_zerop (iv->step))
      {
        record_invariant (data, op, true);
        return NULL;
--- 1163,1169 ----
        return use;
      }
  
!   if (integer_zerop (iv->step))
      {
        record_invariant (data, op, true);
        return NULL;
*************** find_interesting_uses_cond (struct ivopt
*** 1192,1198 ****
    struct iv const_iv;
    tree zero = integer_zero_node;
  
!   const_iv.step = NULL_TREE;
  
    if (TREE_CODE (*cond_p) != SSA_NAME
        && !COMPARISON_CLASS_P (*cond_p))
--- 1195,1201 ----
    struct iv const_iv;
    tree zero = integer_zero_node;
  
!   const_iv.step = integer_zero_node;
  
    if (TREE_CODE (*cond_p) != SSA_NAME
        && !COMPARISON_CLASS_P (*cond_p))
*************** find_interesting_uses_cond (struct ivopt
*** 1224,1246 ****
        (!iv0 || !iv1)
        /* Eliminating condition based on two ivs would be nontrivial.
  	 ??? TODO -- it is not really important to handle this case.  */
!       || (!null_or_integer_zerop (iv0->step)
! 	  && !null_or_integer_zerop (iv1->step)))
      {
        find_interesting_uses_op (data, *op0_p);
        find_interesting_uses_op (data, *op1_p);
        return;
      }
  
!   if (null_or_integer_zerop (iv0->step)
!       && null_or_integer_zerop (iv1->step))
      {
        /* If both are invariants, this is a work for unswitching.  */
        return;
      }
  
    civ = XNEW (struct iv);
!   *civ = null_or_integer_zerop (iv0->step) ? *iv1: *iv0;
    record_use (data, cond_p, civ, stmt, USE_COMPARE);
  }
  
--- 1227,1249 ----
        (!iv0 || !iv1)
        /* Eliminating condition based on two ivs would be nontrivial.
  	 ??? TODO -- it is not really important to handle this case.  */
!       || (!integer_zerop (iv0->step)
! 	  && !integer_zerop (iv1->step)))
      {
        find_interesting_uses_op (data, *op0_p);
        find_interesting_uses_op (data, *op1_p);
        return;
      }
  
!   if (integer_zerop (iv0->step)
!       && integer_zerop (iv1->step))
      {
        /* If both are invariants, this is a work for unswitching.  */
        return;
      }
  
    civ = XNEW (struct iv);
!   *civ = integer_zerop (iv0->step) ? *iv1: *iv0;
    record_use (data, cond_p, civ, stmt, USE_COMPARE);
  }
  
*************** struct ifs_ivopts_data
*** 1285,1291 ****
  {
    struct ivopts_data *ivopts_data;
    tree stmt;
!   tree *step_p;
  };
  
  static bool
--- 1288,1294 ----
  {
    struct ivopts_data *ivopts_data;
    tree stmt;
!   tree step;
  };
  
  static bool
*************** idx_find_step (tree base, tree *idx, voi
*** 1334,1340 ****
  	  ARRAY_REF path below.  */
    *idx = iv->base;
  
!   if (!iv->step)
      return true;
  
    if (TREE_CODE (base) == ARRAY_REF)
--- 1337,1343 ----
  	  ARRAY_REF path below.  */
    *idx = iv->base;
  
!   if (integer_zerop (iv->step))
      return true;
  
    if (TREE_CODE (base) == ARRAY_REF)
*************** idx_find_step (tree base, tree *idx, voi
*** 1360,1370 ****
      }
  
    step = fold_build2 (MULT_EXPR, sizetype, step, iv_step);
! 
!   if (!*dta->step_p)
!     *dta->step_p = step;
!   else
!     *dta->step_p = fold_build2 (PLUS_EXPR, sizetype, *dta->step_p, step);
  
    return true;
  }
--- 1363,1369 ----
      }
  
    step = fold_build2 (MULT_EXPR, sizetype, step, iv_step);
!   dta->step = fold_build2 (PLUS_EXPR, sizetype, dta->step, step);
  
    return true;
  }
*************** may_be_nonaddressable_p (tree expr)
*** 1456,1462 ****
  static void
  find_interesting_uses_address (struct ivopts_data *data, tree stmt, tree *op_p)
  {
!   tree base = *op_p, step = NULL;
    struct iv *civ;
    struct ifs_ivopts_data ifs_ivopts_data;
  
--- 1455,1461 ----
  static void
  find_interesting_uses_address (struct ivopts_data *data, tree stmt, tree *op_p)
  {
!   tree base = *op_p, step = build_int_cst (sizetype, 0);
    struct iv *civ;
    struct ifs_ivopts_data ifs_ivopts_data;
  
*************** find_interesting_uses_address (struct iv
*** 1509,1522 ****
  	      if (TMR_STEP (base))
  		astep = fold_build2 (MULT_EXPR, type, TMR_STEP (base), astep);
  
! 	      if (step)
! 		step = fold_build2 (PLUS_EXPR, type, step, astep);
! 	      else
! 		step = astep;
  	    }
  	}
  
!       if (null_or_integer_zerop (step))
  	goto fail;
        base = tree_mem_ref_addr (type, base);
      }
--- 1508,1518 ----
  	      if (TMR_STEP (base))
  		astep = fold_build2 (MULT_EXPR, type, TMR_STEP (base), astep);
  
! 	      step = fold_build2 (PLUS_EXPR, type, step, astep);
  	    }
  	}
  
!       if (integer_zerop (step))
  	goto fail;
        base = tree_mem_ref_addr (type, base);
      }
*************** find_interesting_uses_address (struct iv
*** 1524,1533 ****
      {
        ifs_ivopts_data.ivopts_data = data;
        ifs_ivopts_data.stmt = stmt;
!       ifs_ivopts_data.step_p = &step;
        if (!for_each_index (&base, idx_find_step, &ifs_ivopts_data)
! 	  || null_or_integer_zerop (step))
  	goto fail;
  
        gcc_assert (TREE_CODE (base) != ALIGN_INDIRECT_REF);
        gcc_assert (TREE_CODE (base) != MISALIGNED_INDIRECT_REF);
--- 1520,1530 ----
      {
        ifs_ivopts_data.ivopts_data = data;
        ifs_ivopts_data.stmt = stmt;
!       ifs_ivopts_data.step = build_int_cst (sizetype, 0);
        if (!for_each_index (&base, idx_find_step, &ifs_ivopts_data)
! 	  || integer_zerop (ifs_ivopts_data.step))
  	goto fail;
+       step = ifs_ivopts_data.step;
  
        gcc_assert (TREE_CODE (base) != ALIGN_INDIRECT_REF);
        gcc_assert (TREE_CODE (base) != MISALIGNED_INDIRECT_REF);
*************** find_interesting_uses_stmt (struct ivopt
*** 1600,1606 ****
  
  	  iv = get_iv (data, lhs);
  
! 	  if (iv && !null_or_integer_zerop (iv->step))
  	    return;
  	}
  
--- 1597,1603 ----
  
  	  iv = get_iv (data, lhs);
  
! 	  if (iv && !integer_zerop (iv->step))
  	    return;
  	}
  
*************** find_interesting_uses_stmt (struct ivopt
*** 1646,1652 ****
        lhs = PHI_RESULT (stmt);
        iv = get_iv (data, lhs);
  
!       if (iv && !null_or_integer_zerop (iv->step))
  	return;
      }
  
--- 1643,1649 ----
        lhs = PHI_RESULT (stmt);
        iv = get_iv (data, lhs);
  
!       if (iv && !integer_zerop (iv->step))
  	return;
      }
  
*************** find_interesting_uses_outside (struct iv
*** 1676,1682 ****
    for (phi = phi_nodes (exit->dest); phi; phi = PHI_CHAIN (phi))
      {
        def = PHI_ARG_DEF_FROM_EDGE (phi, exit);
!       find_interesting_uses_op (data, def);
      }
  }
  
--- 1673,1680 ----
    for (phi = phi_nodes (exit->dest); phi; phi = PHI_CHAIN (phi))
      {
        def = PHI_ARG_DEF_FROM_EDGE (phi, exit);
!       if (is_gimple_reg (def))
! 	find_interesting_uses_op (data, def);
      }
  }
  
*************** add_candidate_1 (struct ivopts_data *dat
*** 1944,1951 ****
        if (type != orig_type)
  	{
  	  base = fold_convert (type, base);
! 	  if (step)
! 	    step = fold_convert (type, step);
  	}
      }
  
--- 1942,1948 ----
        if (type != orig_type)
  	{
  	  base = fold_convert (type, base);
! 	  step = fold_convert (type, step);
  	}
      }
  
*************** add_candidate_1 (struct ivopts_data *dat
*** 1970,1988 ****
        if (!base && !step)
  	continue;
  
!       if (!operand_equal_p (base, cand->iv->base, 0))
! 	continue;
! 
!       if (null_or_integer_zerop (cand->iv->step))
! 	{
! 	  if (null_or_integer_zerop (step))
! 	    break;
! 	}
!       else
! 	{
! 	  if (step && operand_equal_p (step, cand->iv->step, 0))
! 	    break;
! 	}
      }
  
    if (i == n_iv_cands (data))
--- 1967,1975 ----
        if (!base && !step)
  	continue;
  
!       if (operand_equal_p (base, cand->iv->base, 0)
! 	  && operand_equal_p (step, cand->iv->step, 0))
! 	break;
      }
  
    if (i == n_iv_cands (data))
*************** add_old_ivs_candidates (struct ivopts_da
*** 2136,2142 ****
    EXECUTE_IF_SET_IN_BITMAP (data->relevant, 0, i, bi)
      {
        iv = ver_info (data, i)->iv;
!       if (iv && iv->biv_p && !null_or_integer_zerop (iv->step))
  	add_old_iv_candidates (data, iv);
      }
  }
--- 2123,2129 ----
    EXECUTE_IF_SET_IN_BITMAP (data->relevant, 0, i, bi)
      {
        iv = ver_info (data, i)->iv;
!       if (iv && iv->biv_p && !integer_zerop (iv->step))
  	add_old_iv_candidates (data, iv);
      }
  }
*************** determine_use_iv_cost_condition (struct 
*** 3733,3739 ****
      {
        op = TREE_OPERAND (cond, 0);
        if (TREE_CODE (op) == SSA_NAME
! 	  && !null_or_integer_zerop (get_iv (data, op)->step))
  	op = TREE_OPERAND (cond, 1);
        if (TREE_CODE (op) == SSA_NAME)
  	{
--- 3720,3726 ----
      {
        op = TREE_OPERAND (cond, 0);
        if (TREE_CODE (op) == SSA_NAME
! 	  && !integer_zerop (get_iv (data, op)->step))
  	op = TREE_OPERAND (cond, 1);
        if (TREE_CODE (op) == SSA_NAME)
  	{
*************** rewrite_use_compare (struct ivopts_data 
*** 5151,5157 ****
    cond = *use->op_p;
    op_p = &TREE_OPERAND (cond, 0);
    if (TREE_CODE (*op_p) != SSA_NAME
!       || null_or_integer_zerop (get_iv (data, *op_p)->step))
      op_p = &TREE_OPERAND (cond, 1);
  
    op = force_gimple_operand (comp, &stmts, true, SSA_NAME_VAR (*op_p));
--- 5138,5144 ----
    cond = *use->op_p;
    op_p = &TREE_OPERAND (cond, 0);
    if (TREE_CODE (*op_p) != SSA_NAME
!       || integer_zerop (get_iv (data, *op_p)->step))
      op_p = &TREE_OPERAND (cond, 1);
  
    op = force_gimple_operand (comp, &stmts, true, SSA_NAME_VAR (*op_p));
*************** remove_unused_ivs (struct ivopts_data *d
*** 5222,5228 ****
  
        info = ver_info (data, j);
        if (info->iv
! 	  && !null_or_integer_zerop (info->iv->step)
  	  && !info->inv_id
  	  && !info->iv->have_use_for
  	  && !info->preserve_biv)
--- 5209,5215 ----
  
        info = ver_info (data, j);
        if (info->iv
! 	  && !integer_zerop (info->iv->step)
  	  && !info->inv_id
  	  && !info->iv->have_use_for
  	  && !info->preserve_biv)
Index: tree-ssa-loop-prefetch.c
===================================================================
*** tree-ssa-loop-prefetch.c	(revision 120156)
--- tree-ssa-loop-prefetch.c	(working copy)
*************** idx_analyze_ref (tree base, tree *index,
*** 337,350 ****
    ibase = iv.base;
    step = iv.step;
  
!   if (null_or_integer_zerop (step))
!     istep = 0;
!   else
!     {
!       if (!cst_and_fits_in_hwi (step))
! 	return false;
!       istep = int_cst_value (step);
!     }
  
    if (TREE_CODE (ibase) == PLUS_EXPR
        && cst_and_fits_in_hwi (TREE_OPERAND (ibase, 1)))
--- 337,345 ----
    ibase = iv.base;
    step = iv.step;
  
!   if (!cst_and_fits_in_hwi (step))
!     return false;
!   istep = int_cst_value (step);
  
    if (TREE_CODE (ibase) == PLUS_EXPR
        && cst_and_fits_in_hwi (TREE_OPERAND (ibase, 1)))


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]