[Bug tree-optimization/113433] [12/13/14 Regression] Missed optimization for redundancy computation elimination

2024-03-08 Thread law at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113433

Jeffrey A. Law  changed:

   What|Removed |Added

 CC||law at gcc dot gnu.org

--- Comment #2 from Jeffrey A. Law  ---
So we could attack this as a DOM problem.  Not all the infrastructure is in
there.  But the recognition of negated expressions isn't hard.  Something like
this in tree-ssa-scopedtables will detect the negated expression in the hash
table.  

/* We might be able to lookup the negated expression.  */
case PLUS_EXPR:
  {
tree x = gimple_assign_rhs_to_tree (stmt);
x = fold_unary (NEGATE_EXPR, TREE_TYPE (x), x);
struct hashable_expr expr;
expr.type = TREE_TYPE (x);
expr.kind = EXPR_BINARY;
expr.ops.binary.op = MINUS_EXPR;
expr.ops.binary.opnd0 = TREE_OPERAND (x, 0);
expr.ops.binary.opnd1 = TREE_OPERAND (x, 1);
class expr_hash_elt element2 (, NULL_TREE);
expr_hash_elt **slot
  = m_avail_exprs->find_slot (, NO_INSERT);
if (slot && *slot)
  return fold_build1 (NEGATE_EXPR, TREE_TYPE (x),  (*slot)->lhs
());
return NULL_TREE;
  }

Right now DOM isn't prepared for avail_expr_stack::simplify_binary_operation to
return anything other than a constant, ssa_name or NULL.  But how hard could it
be to expand further :-)


Not sure if this happens enough to make the extra lookups worth the effort.

[Bug tree-optimization/113433] [12/13/14 Regression] Missed optimization for redundancy computation elimination

2024-01-17 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113433

Richard Biener  changed:

   What|Removed |Added

   Priority|P3  |P2
   Target Milestone|--- |12.4

[Bug tree-optimization/113433] [12/13/14 Regression] Missed optimization for redundancy computation elimination

2024-01-16 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113433

Andrew Pinski  changed:

   What|Removed |Added

   Keywords||missed-optimization
 Ever confirmed|0   |1
 Status|UNCONFIRMED |ASSIGNED
   Last reconfirmed||2024-01-17
   Assignee|unassigned at gcc dot gnu.org  |pinskia at gcc dot 
gnu.org

--- Comment #1 from Andrew Pinski  ---
But it is a similar issue, we are left with:
  _1 = 1 - y_7(D);
  _5 = y_7(D) + -1;
  _6 = _1 / _5;

Which is not folded as being as we don't know that `1 - x` and `x + -1` are
negative opposites.