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

[Bug c++/84357] [8 Regression] Incorrect 'foo' is used uninitialized with -O3


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84357

--- Comment #3 from rsandifo at gcc dot gnu.org <rsandifo at gcc dot gnu.org> ---
Author: rsandifo
Date: Wed Feb 14 13:14:51 2018
New Revision: 257657

URL: https://gcc.gnu.org/viewcvs?rev=257657&root=gcc&view=rev
Log:
Check array indices in object_address_invariant_in_loop_p (PR 84357)

object_address_invariant_in_loop_p ignored ARRAY_REF indices on
the basis that:

          /* Index of the ARRAY_REF was zeroed in analyze_indices, thus we only
             need to check the stride and the lower bound of the reference.  */

That was true back in 2007 when the code was added:

static void
dr_analyze_indices (struct data_reference *dr, struct loop *nest)
{
  [...]
  while (handled_component_p (aref))
    {
      if (TREE_CODE (aref) == ARRAY_REF)
        {
          op = TREE_OPERAND (aref, 1);
          access_fn = analyze_scalar_evolution (loop, op);
          access_fn = resolve_mixers (nest, access_fn);
          VEC_safe_push (tree, heap, access_fns, access_fn);

          TREE_OPERAND (aref, 1) = build_int_cst (TREE_TYPE (op), 0);
        }

      aref = TREE_OPERAND (aref, 0);
    }

but the assignment was removed a few years ago.  We were therefore
treating "two->arr[i]" and "three->arr[i]" as loop invariant.

2018-02-14  Richard Sandiford  <richard.sandiford@linaro.org>

gcc/
        PR tree-optimization/84357
        * tree-data-ref.c (object_address_invariant_in_loop_p): Check
        operand 1 of an ARRAY_REF too.

gcc/testsuite/
        PR tree-optimization/84357
        * gcc.dg/vect/pr84357.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/vect/pr84357.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-data-ref.c

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