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/114326] Missed optimization for A || B when !B implies A.
Date: Wed, 13 Mar 2024 21:41:47 +0000 [thread overview]
Message-ID: <bug-114326-4-RVv5yzlx8B@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-114326-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114326
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to ptomsich from comment #2)
> To copy the last piece of info from our internal tracker...
>
> LLVM learned this new trick only in the run-up to LLVM 18.
> Up until then, GCC and LLVM performed identically on this snippet.
Yes it looks like it is pattern matching what I suggested (well with and
without the and).
Note we do need another pattern, one without the bit_and:
(simplify
(bit_ior
(ne@n4 @0 @1)
(cmp
(bit_xor @0 @1)
@2))
(bit_ior @n4
(cmp { build_zero_cst (TREE_TYPE (@0)); } @2))
)
And we need one more for bit_ior:
(simplify
(bit_ior
(ne@n4 @0 @1)
(cmp
(bit_ior
(bit_xor @0 @1)
@2)
@3))
(bit_ior @n4
(cmp @2 @3))
)
Note it looks like clang does not handle non-contants that well, (they handle d
== 0 though).
E.g.:
```
int foo(void);
int cmp1(unsigned d1, unsigned d2, unsigned c, unsigned d) {
int t = ((d1 ^ d2) & c ) == (d);
int t1 = d1 != d2;
int tt = t | t1;
return tt;
}
```
Should be optimized to:
int foo(void);
int cmp1(unsigned d1, unsigned d2, unsigned c, unsigned d) {
int t = 0 == d;
int t1 = d1 != d2;
int tt = t | t1;
return tt;
}
```
prev parent reply other threads:[~2024-03-13 21:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-13 14:19 [Bug tree-optimization/114326] New: " manolis.tsamis at vrull dot eu
2024-03-13 19:06 ` [Bug tree-optimization/114326] " pinskia at gcc dot gnu.org
2024-03-13 21:18 ` ptomsich at gcc dot gnu.org
2024-03-13 21:41 ` pinskia at gcc dot gnu.org [this message]
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-114326-4-RVv5yzlx8B@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: link
Be 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).