public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "glisse at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/57755] New: Improve fold_binary_op_with_conditional_arg Date: Fri, 28 Jun 2013 18:02:00 -0000 [thread overview] Message-ID: <bug-57755-4@http.gcc.gnu.org/bugzilla/> (raw) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57755 Bug ID: 57755 Summary: Improve fold_binary_op_with_conditional_arg Product: gcc Version: 4.9.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: glisse at gcc dot gnu.org Hello, fold_binary_op_with_conditional_arg performs the following: Transform `a + (b ? x : y)' into `b ? (a + x) : (a + y)'. Transform, `a + (x < y)' into `(x < y) ? (a + 1) : (a + 0)'. It gives up in this first case (arg is 'a' above): if (!TREE_CONSTANT (arg) && (TREE_SIDE_EFFECTS (arg) || TREE_CODE (arg) == COND_EXPR || TREE_CODE (arg) == VEC_COND_EXPR || TREE_CONSTANT (true_value) || TREE_CONSTANT (false_value))) return NULL_TREE; and after folding both branches: if (!TREE_CONSTANT (arg) && !TREE_CONSTANT (lhs) && !TREE_CONSTANT (rhs)) return NULL_TREE; This seems suboptimal. On the one hand, for ((a<b)?a:c)*3/2+1, it distributes the operations to a < b ? (a * 3) / 2 + 1 : (c * 3) / 2 + 1 (we can add as many operations with constants as we want) and this isn't completely undone later (partially with -Os, not at all with -O3). On the other hand, for ((a<2)?-1u:0)&b, it gives up instead of producing (a<2)?b:0. We must be careful with recursions (PR55219) and with folders performing the reverse transformations, but I think we should be able to optimize: (((a<2)?-1:0)&((b<1)?-1:0))!=0 (obviously, the title doesn't prevent from moving this functionality to gimple)
next reply other threads:[~2013-06-28 18:02 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2013-06-28 18:02 glisse at gcc dot gnu.org [this message] 2013-06-29 0:06 ` [Bug tree-optimization/57755] " glisse at gcc dot gnu.org 2023-05-05 7:39 ` pinskia at gcc dot gnu.org 2023-05-05 7:43 ` pinskia at gcc dot gnu.org 2023-09-15 20:43 ` pinskia at gcc dot gnu.org 2023-09-16 2:23 ` 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-57755-4@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: linkBe 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).