public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/106379] DCE depends on order Date: Thu, 21 Jul 2022 09:48:52 +0000 [thread overview] Message-ID: <bug-106379-4-PJSAH2DJ4B@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-106379-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106379 Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |missed-optimization Ever confirmed|0 |1 Status|UNCONFIRMED |ASSIGNED Last reconfirmed| |2022-07-21 CC| |amacleod at redhat dot com Component|c |tree-optimization --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- Confirmed. We don't recognize the pattern in GENERIC folding, instead for the good case VRP1 handles _Bool _1; _Bool _2; <bb 2> [local count: 1073741824]: _1 = ~c_4(D); if (c_4(D) != s_5(D)) goto <bb 5>; [66.00%] else goto <bb 3>; [34.00%] <bb 3> [local count: 365072224]: _2 = _1 & s_5(D); if (_2 != 0) goto <bb 4>; [33.00%] else goto <bb 5>; [67.00%] <bb 4> [local count: 120473833]: DCEMarker0_ (); <bb 5> [local count: 1073741824]: return; well while not handling _Bool _1; _Bool _2; <bb 2> [local count: 1073741824]: if (s_4(D) != c_5(D)) goto <bb 5>; [66.00%] else goto <bb 3>; [34.00%] <bb 3> [local count: 365072224]: _1 = ~c_5(D); _2 = _1 & s_4(D); if (_2 != 0) goto <bb 4>; [33.00%] else goto <bb 5>; [67.00%] <bb 4> [local count: 120473833]: DCEMarker0_ (); <bb 5> [local count: 1073741824]: return; we are probably very early defeating equivalence handling by folding !a == !b to !a ^ b (and which one gets the inversion depends on the order which is the underlying issue this PR points out). It's also apparent that we fail to simplify !a == !b to a == b for boolean a, b. We arrive there via fold_binary_loc's /* ARG0 is the first operand of EXPR, and ARG1 is the second operand. First check for cases where an arithmetic operation is applied to a compound, conditional, or comparison operation. Push the arithmetic operation inside the compound or conditional to see if any folding can then be done. Convert comparison to conditional for this purpose. The also optimizes non-constant cases that used to be done in expand_expr. Before we do that, see if this is a BIT_AND_EXPR or a BIT_IOR_EXPR, one of the operands is a comparison and the other is a comparison, a BIT_AND_EXPR with the constant 1, or a truth value. In that case, the code below would make the expression more complex. Change it to a TRUTH_{AND,OR}_EXPR. Likewise, convert a similar NE_EXPR to TRUTH_XOR_EXPR and an EQ_EXPR to the inversion of a TRUTH_XOR_EXPR. */ which generates !a ^ !b which is eventually inverted to !a ^ b. Adding (simplify (bit_not (bit_xor truth_valued_p@0 truth_valued_p@1)) (eq @0 @1)) fixes this but code generation of _Bool foo (_Bool a, _Bool b) { return !a == !b; } changes from xorl %edi, %esi movl %esi, %eax xorl $1, %eax ret to cmpb %sil, %dil sete %al
next prev parent reply other threads:[~2022-07-21 9:48 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-07-21 9:13 [Bug c/106379] New: " tmayerl at student dot ethz.ch 2022-07-21 9:48 ` rguenth at gcc dot gnu.org [this message] 2022-07-21 11:23 ` [Bug tree-optimization/106379] " rguenth at gcc dot gnu.org 2022-07-21 11:24 ` cvs-commit at gcc dot gnu.org 2022-08-08 20:36 ` amacleod at redhat dot com 2023-05-18 17:26 ` pinskia at gcc dot gnu.org 2023-07-13 18:39 ` pinskia at gcc dot gnu.org 2023-09-17 5:46 ` 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-106379-4-PJSAH2DJ4B@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).