public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "law at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/113433] [12/13/14 Regression] Missed optimization for redundancy computation elimination
Date: Sat, 09 Mar 2024 04:40:24 +0000	[thread overview]
Message-ID: <bug-113433-4-mXWfZ274mo@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-113433-4@http.gcc.gnu.org/bugzilla/>

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

Jeffrey A. Law <law at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |law at gcc dot gnu.org

--- Comment #2 from Jeffrey A. Law <law at gcc dot gnu.org> ---
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 (&expr, NULL_TREE);
                expr_hash_elt **slot
                  = m_avail_exprs->find_slot (&element2, 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.

  parent reply	other threads:[~2024-03-09  4:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-17  2:55 [Bug tree-optimization/113433] New: " 652023330028 at smail dot nju.edu.cn
2024-01-17  3:08 ` [Bug tree-optimization/113433] " pinskia at gcc dot gnu.org
2024-01-17  8:09 ` rguenth at gcc dot gnu.org
2024-03-09  4:40 ` law at gcc dot gnu.org [this message]
2024-05-26  5:43 ` [Bug tree-optimization/113433] [12/13/14/15 " pinskia at gcc dot gnu.org
2024-05-26  5:43 ` pinskia at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-113433-4-mXWfZ274mo@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).