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 tree-optimization/78343] [6/7 Regression] Loop is not eliminated


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

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Previously handled by the loop_depth check I guess.  Note that in

void
record_temporary_equivalences (edge e,
                               class const_and_copies *const_and_copies,
                               class avail_exprs_stack *avail_exprs_stack)
{
...
      /* Record the simple NAME = VALUE equivalence.  */
      tree rhs = edge_info->rhs;
      record_equality (lhs, rhs, const_and_copies);

      /* We already recorded that LHS = RHS, with canonicalization,
         value chain following, etc.

         We also want to record RHS = LHS, but without any canonicalization
         or value chain following.  */
      if (TREE_CODE (rhs) == SSA_NAME)
        const_and_copies->record_const_or_copy_raw (rhs, lhs,
                                                    SSA_NAME_VALUE (rhs));

we eventually (as in this case) record the same equality twice given
record_equality performs canonicalization:

Optimizing block #4

1>>> STMT 1 = i_6 le_expr quant_3(D)
1>>> STMT 1 = i_6 ge_expr quant_3(D)
1>>> STMT 1 = i_6 eq_expr quant_3(D)
1>>> STMT 0 = i_6 ne_expr quant_3(D)
0>>> COPY quant_3(D) = i_6
0>>> COPY quant_3(D) = i_6
Optimizing statement sum_2 = quant_3(D) * quant_3(D);
  Replaced 'quant_3(D)' with variable 'i_6'
  Replaced 'quant_3(D)' with variable 'i_6'

in the IL we have a non-canonical compare:

<bb 3>:
# i_11 = PHI <i_6(7), 0(6)>
i_6 = i_11 + 1;
if (i_6 != quant_3(D))

IVOPT transforms

  if (quant_3(D) > i_6)
    goto <bb 6>;

to

  if (i_6 != quant_3(D))
    goto <bb 6>;

(both just as side-notes, not really relevant to this PR).

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