public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/95034] Failure to convert xor pattern (made out of or+and) to xor Date: Wed, 23 Aug 2023 02:16:53 +0000 [thread overview] Message-ID: <bug-95034-4-H2XmIWmDQ1@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-95034-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95034 --- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> --- So after phiopt2 we end up with: ``` _1 = a_3(D) | b_4(D); if (_1 != 0) goto <bb 3>; [50.00%] else goto <bb 4>; [50.00%] <bb 3> [local count: 536870912]: _5 = a_3(D) & b_4(D); _7 = ~_5; <bb 4> [local count: 1073741824]: # iftmp.0_2 = PHI <_7(3), 0(2)> ``` Phi-opt does not support more than one statement inside the middle BB so it does nothing here. But if we rewrite it such that the 2 statements were not inside the middle BB by phiopt2, we get the xor as expected. That is: ``` bool f(bool a, bool b) { bool c = a | b; bool d = a & b; d = !d; return c ? d : false; } ``` Will produce: ``` _8 = a_3(D) ^ b_4(D); return _8; ``` From the phiopt2 dump: ``` Folded into the sequence: _8 = a_3(D) ^ b_4(D); ``` I wonder if we could support more than 1 statement in the middle BBs iff the resulting simplifications only reference one SSA_NAME of the statements max ...
next prev parent reply other threads:[~2023-08-23 2:17 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-05-10 9:48 [Bug tree-optimization/95034] New: Pattern for xor not converted " gabravier at gmail dot com 2020-05-13 12:38 ` [Bug tree-optimization/95034] Failure to convert xor pattern (made out of or+and) " pinskia at gcc dot gnu.org 2021-01-12 10:33 ` jakub at gcc dot gnu.org 2021-01-12 10:56 ` jakub at gcc dot gnu.org 2021-01-12 11:03 ` jakub at gcc dot gnu.org 2021-01-12 12:12 ` jakub at gcc dot gnu.org 2021-04-17 21:03 ` pinskia at gcc dot gnu.org 2023-08-23 2:16 ` pinskia at gcc dot gnu.org [this message] 2023-10-17 4:39 ` 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-95034-4-H2XmIWmDQ1@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).