This is the mail archive of the 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]

Re: [tuples, commited] Scalar evolution analysis

On Tue, Mar 4, 2008 at 8:25 PM, Zdenek Dvorak <> wrote:
>  this patch tuplifies scalar evolution analysis and # of iterations
>  analysis.  It also fixes problems with pass_ch (gimple_copy used to
>  share bitmaps between the original and copied statement, which caused
>  the bitmaps to be freed twice, which leads to quite cryptic ICEs)
>  and enables it, and tuplifies and enables pass_scev_cprop.

After this patch, my build (with -Werror) failed with a warning regarding a
possibly unitialized variable.  I silenced the warning with the attached patch.

The code here is a bit subtle.  The call to no_evolution_in_loop_p
fails to set its output argument RES precisely in the case that it
returns false,
which prevents the uninitialized value from being subsequently read.  The
relevant snippet of code appears below:

/* Determines whether CHREC is a loop invariant with respect to LOOP_NUM.
   Set the result in RES and return true when the property can be computed.  */

static inline bool
no_evolution_in_loop_p (tree chrec, unsigned loop_num, bool *res)
  tree scev;

  if (chrec == chrec_not_analyzed_yet
      || chrec == chrec_dont_know
      || chrec_contains_symbols_defined_in_loop (chrec, loop_num))
    return false;

  scev = hide_evolution_in_other_loops_than_loop (chrec, loop_num);
  *res = !tree_is_chrec (scev);
  return true;

/* Build a polynomial chain of recurrence.  */

static inline tree
build_polynomial_chrec (unsigned loop_num,
			tree left,
			tree right)
  /* Avoid unitialized var warning on some compilers.  */
  bool val = false;

  if (left == chrec_dont_know
      || right == chrec_dont_know)
    return chrec_dont_know;

  if (no_evolution_in_loop_p (left, loop_num, &val) && !val)
    return chrec_dont_know;

  /* Pointer types should occur only on the left hand side, i.e. in
     the base of the chrec, and not in the step.  */
  gcc_assert (!POINTER_TYPE_P (TREE_TYPE (right)));

  /* Types of left and right sides of a chrec should be compatible.  */
  if (POINTER_TYPE_P (TREE_TYPE (left)))
    gcc_assert (sizetype == TREE_TYPE (right));
    gcc_assert (TREE_TYPE (left) == TREE_TYPE (right));

  if (chrec_zerop (right))
    return left;

  return build3 (POLYNOMIAL_CHREC, TREE_TYPE (left),
		 build_int_cst (NULL_TREE, loop_num), left, right);

Attachment: patch-bogus-uninit-var.txt
Description: Text document

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