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/110111] bool patterns that should produce a?b:c Date: Tue, 29 Aug 2023 05:27:05 +0000 [thread overview] Message-ID: <bug-110111-4-gcR7S1BR74@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-110111-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110111 --- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- f1: _6 = b_2(D) ^ c_3(D); _7 = a_1(D) & _6; _4 = c_3(D) ^ _7; Which was done due to: /* (x & ~m) | (y & m) -> ((x ^ y) & m) ^ x */ (simplify (bit_ior:c (bit_and:cs @0 (bit_not @2)) (bit_and:cs @1 @2)) (bit_xor (bit_and (bit_xor @0 @1) @2) @0)) Note if we move this over to bitwise_inverted_equal_p (which we should), we will lose also: ``` bool f(int a, int b, int t) { bool x = a == 0; bool y = b == 1; bool m = t == 2; bool mp = !m; return (x & mp) | (y & m); } ``` Which is currently handled. We should check for `element_precision (type) == 1` too. So something like: (simplify (bit_ior (bit_and:c@and1 @0 @3) (bit_and:c@and2 @1 @2)) (with { bool wascmp; } (if (bitwise_inverted_equal_p (@0, @2, wascmp)) (switch /* For 1bit, wascmp can be true and we can just convert it into `m ? y : x` */ (if (INTEGRAL_TYPE_P (type) && element_precision (type) == 1) (cond @3 @0 @1)) (if (!wascmp && element_precision (type) != 1 && single_use (@and1) && single_use (@and2)) (bit_xor (bit_and (bit_xor @0 @1) @2) @0)) ) ) ) ) ) /* 1bit `((x ^ y) & m) ^ x` should just be convert into `m ? y : x` early */ (simplify (bit_xor:c (bit_and:c (bit_xor:c @0 @1) @2) @0) (if (INTEGRAL_TYPE_P (type) && element_precision (type) == 1) (cond @2 @0 @1)))
next prev parent reply other threads:[~2023-08-29 5:27 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-06-04 8:15 [Bug tree-optimization/110111] New: " pinskia at gcc dot gnu.org 2023-07-12 6:20 ` [Bug tree-optimization/110111] " pinskia at gcc dot gnu.org 2023-08-24 6:47 ` pinskia at gcc dot gnu.org 2023-08-29 5:27 ` pinskia at gcc dot gnu.org [this message] 2023-08-29 8:10 ` 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-110111-4-gcR7S1BR74@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).