public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "ktietz at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/33512] Simple bitwise simplification missed Date: Tue, 24 Apr 2012 08:31:00 -0000 [thread overview] Message-ID: <bug-33512-4-tqBZO8283d@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-33512-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33512 --- Comment #14 from Kai Tietz <ktietz at gcc dot gnu.org> 2012-04-24 08:30:49 UTC --- Hmm, I have right now in my tree Index: tree-ssa-forwprop.c =================================================================== --- tree-ssa-forwprop.c (revision 186753) +++ tree-ssa-forwprop.c (working copy) @@ -1912,17 +1912,25 @@ /* Simplify (A & B) OP0 (C & B) to (A OP0 C) & B. */ if (def1_code == def2_code - && def1_code == BIT_AND_EXPR - && operand_equal_for_phi_arg_p (gimple_assign_rhs2 (def1), - gimple_assign_rhs2 (def2))) + && def1_code == BIT_AND_EXPR) { - tree b = gimple_assign_rhs2 (def1); - tree a = def1_arg1; - tree c = def2_arg1; - tree inner = fold_build2 (code, TREE_TYPE (arg2), a, c); + tree inner, a = NULL_TREE, b = NULL_TREE, c = NULL_TREE; + + if (operand_equal_for_phi_arg_p (def1_arg2, def2_arg2)) + { b = def1_arg2; a = def1_arg1; c = def2_arg1; } + else if (operand_equal_for_phi_arg_p (def1_arg1, def2_arg1)) + { b = def1_arg1; a = def1_arg2; c = def2_arg2; } + else if (operand_equal_for_phi_arg_p (def1_arg1, def2_arg2)) + { b = def1_arg1; a = def1_arg2; c = def2_arg1; } + else if (operand_equal_for_phi_arg_p (def1_arg2, def2_arg1)) + { b = def1_arg2; a = def1_arg1; c = def2_arg2; } + if (a && c) + inner = fold_build2 (code, TREE_TYPE (arg2), a, c); + if (!a || !b || !c) + ; /* If A OP0 C (this usually means C is the same as A) is 0 then fold it down correctly. */ - if (integer_zerop (inner)) + else if (integer_zerop (inner)) { gimple_assign_set_rhs_from_tree (gsi, inner); update_stmt (stmt); It has the advantage of handling also cases for (A & B) OP0 (C & B) to (A OP0 C) & B, (B & A) OP0 (C & B) to (A OP0 C) & B, (A & B) OP0 (B & C) to (A OP0 C) & B, and (B & A) OP0 (B & C) to (A OP0 C) & B. It bootstraps fine.
next prev parent reply other threads:[~2012-04-24 8:31 UTC|newest] Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <bug-33512-4@http.gcc.gnu.org/bugzilla/> 2012-04-24 7:06 ` pinskia at gcc dot gnu.org 2012-04-24 7:07 ` pinskia at gcc dot gnu.org 2012-04-24 7:39 ` ktietz at gcc dot gnu.org 2012-04-24 8:24 ` pinskia at gcc dot gnu.org 2012-04-24 8:31 ` ktietz at gcc dot gnu.org [this message] 2012-04-24 8:38 ` pinskia at gcc dot gnu.org 2012-04-24 8:57 ` pinskia at gcc dot gnu.org 2007-09-20 22:32 [Bug rtl-optimization/33512] New: " pinskia at gcc dot gnu dot org 2008-02-23 18:02 ` [Bug tree-optimization/33512] " pinskia at gcc dot gnu dot org 2008-04-04 21:20 ` janis at gcc dot gnu dot org 2008-04-04 21:22 ` pinskia at gcc dot gnu dot org 2008-07-15 14:54 ` pinskia at gcc dot gnu dot org 2008-11-23 18:46 ` pinskia at gcc dot gnu dot org 2010-07-02 19:52 ` bergner at gcc dot gnu dot 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-33512-4-tqBZO8283d@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).