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/91882] boolean XOR tautology missed optimisation Date: Sat, 26 Nov 2022 17:41:19 +0000 [thread overview] Message-ID: <bug-91882-4-AohQerTWaG@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-91882-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91882 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |103356 --- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> --- After my patch for PR 103356, this is fixed. Before pre: _1 = a_4(D) ^ b_5(D); _2 = a_4(D) | b_5(D); if (_2 != 0) goto <bb 3>; [50.00%] else goto <bb 4>; [50.00%] <bb 3> [local count: 536870913]: _6 = a_4(D) & b_5(D); _9 = ~_6; <bb 4> [local count: 1073741824]: # iftmp.0_3 = PHI <_9(3), 0(2)> _7 = _1 == iftmp.0_3; After PRE (after my patch): _1 = a_4(D) ^ b_5(D); _2 = a_4(D) | b_5(D); if (_2 != 0) goto <bb 4>; [50.00%] else goto <bb 3>; [50.00%] <bb 3> [local count: 536870912]: _10 = ~_1; goto <bb 5>; [100.00%] <bb 4> [local count: 536870913]: // _6 = a_4(D) & b_5(D); // _9 = ~_6; <bb 5> [local count: 1073741824]: # iftmp.0_3 = PHI <_9(4), 0(3)> # prephitmp_11 = PHI <_2(4), _10(3)> return prephitmp_11; And then dom comes and does (because if (a|b) == 0 then both a and b are zero and a^b == 0 and ~(a^b) is 1): <bb 2> [local count: 1073741824]: _2 = a_4(D) | b_5(D); if (_2 != 0) goto <bb 4>; [50.00%] else goto <bb 3>; [50.00%] <bb 3> [local count: 536870912]: _1 = 0; _10 = 1; <bb 4> [local count: 1073741824]: # prephitmp_11 = PHI <1(2), 1(3)> return 1; Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103356 [Bug 103356] bool0 == ~bool1 should simplify to bool1 ^ bool0
next prev parent reply other threads:[~2022-11-26 17:41 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <bug-91882-4@http.gcc.gnu.org/bugzilla/> 2020-08-05 21:56 ` sucicf1 at outlook dot com 2020-08-05 22:00 ` sucicf1 at outlook dot com 2022-11-26 17:41 ` pinskia at gcc dot gnu.org [this message] 2022-11-26 17:44 ` pinskia at gcc dot gnu.org 2022-11-26 18:01 ` pinskia at gcc dot gnu.org 2022-11-26 18:03 ` pinskia at gcc dot gnu.org 2022-11-28 2:58 ` 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-91882-4-AohQerTWaG@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).