public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug middle-end/100798] New: a?~t:t and (-(!!a))^t don't produce the same assembly code @ 2021-05-27 10:39 pinskia at gcc dot gnu.org 2023-05-20 2:25 ` [Bug middle-end/100798] " pinskia at gcc dot gnu.org ` (4 more replies) 0 siblings, 5 replies; 6+ messages in thread From: pinskia at gcc dot gnu.org @ 2021-05-27 10:39 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100798 Bug ID: 100798 Summary: a?~t:t and (-(!!a))^t don't produce the same assembly code Product: gcc Version: 12.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- While working on non GCC code, I notice these two functions don't produce the assembly code: int f(int a, int t) { return (a=='s' ? ~t : t); } int f1(int a, int t) { int t1 = -(a=='s'); return (t1 ^ t); } For aarch64, the first case produce the best, while on x86_64, I don't know which is better, sete or cmov. Note LLVM produces the same code for both, for aarch64, the csinv and sete/neg/xor for x86_64. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/100798] a?~t:t and (-(!!a))^t don't produce the same assembly code 2021-05-27 10:39 [Bug middle-end/100798] New: a?~t:t and (-(!!a))^t don't produce the same assembly code pinskia at gcc dot gnu.org @ 2023-05-20 2:25 ` pinskia at gcc dot gnu.org 2023-08-07 19:04 ` pinskia at gcc dot gnu.org ` (3 subsequent siblings) 4 siblings, 0 replies; 6+ messages in thread From: pinskia at gcc dot gnu.org @ 2023-05-20 2:25 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100798 --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- To produce the same code we could do a match pattern: (simplify (cond @0 (bit_not @1) @1) (bit_xor (neg (convert @0)) @1)) ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/100798] a?~t:t and (-(!!a))^t don't produce the same assembly code 2021-05-27 10:39 [Bug middle-end/100798] New: a?~t:t and (-(!!a))^t don't produce the same assembly code pinskia at gcc dot gnu.org 2023-05-20 2:25 ` [Bug middle-end/100798] " pinskia at gcc dot gnu.org @ 2023-08-07 19:04 ` pinskia at gcc dot gnu.org 2023-08-08 0:55 ` pinskia at gcc dot gnu.org ` (2 subsequent siblings) 4 siblings, 0 replies; 6+ messages in thread From: pinskia at gcc dot gnu.org @ 2023-08-07 19:04 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100798 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |pinskia at gcc dot gnu.org Ever confirmed|0 |1 Last reconfirmed| |2023-08-07 Status|UNCONFIRMED |ASSIGNED --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- . ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/100798] a?~t:t and (-(!!a))^t don't produce the same assembly code 2021-05-27 10:39 [Bug middle-end/100798] New: a?~t:t and (-(!!a))^t don't produce the same assembly code pinskia at gcc dot gnu.org 2023-05-20 2:25 ` [Bug middle-end/100798] " pinskia at gcc dot gnu.org 2023-08-07 19:04 ` pinskia at gcc dot gnu.org @ 2023-08-08 0:55 ` pinskia at gcc dot gnu.org 2023-08-09 19:22 ` cvs-commit at gcc dot gnu.org 2023-08-09 19:27 ` pinskia at gcc dot gnu.org 4 siblings, 0 replies; 6+ messages in thread From: pinskia at gcc dot gnu.org @ 2023-08-08 0:55 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100798 --- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Patch posted: https://gcc.gnu.org/pipermail/gcc-patches/2023-August/626580.html ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/100798] a?~t:t and (-(!!a))^t don't produce the same assembly code 2021-05-27 10:39 [Bug middle-end/100798] New: a?~t:t and (-(!!a))^t don't produce the same assembly code pinskia at gcc dot gnu.org ` (2 preceding siblings ...) 2023-08-08 0:55 ` pinskia at gcc dot gnu.org @ 2023-08-09 19:22 ` cvs-commit at gcc dot gnu.org 2023-08-09 19:27 ` pinskia at gcc dot gnu.org 4 siblings, 0 replies; 6+ messages in thread From: cvs-commit at gcc dot gnu.org @ 2023-08-09 19:22 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100798 --- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Andrew Pinski <pinskia@gcc.gnu.org>: https://gcc.gnu.org/g:7fb65f102851248bafa0815401d8bdcea6d7626c commit r14-3110-g7fb65f102851248bafa0815401d8bdcea6d7626c Author: Andrew Pinski <apinski@marvell.com> Date: Mon Aug 7 10:47:09 2023 -0700 MATCH: [PR110937/PR100798] (a ? ~b : b) should be optimized to b ^ -(a) This adds a simple match pattern for this case. I noticed it a couple of different places. One while I was looking at code generation of a parser and also while I was looking at locations where bitwise_inverted_equal_p should be used more. Committed as approved after bootstrapped and tested on x86_64-linux-gnu with no regressions. PR tree-optimization/110937 PR tree-optimization/100798 gcc/ChangeLog: * match.pd (`a ? ~b : b`): Handle this case. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/bool-14.c: New test. * gcc.dg/tree-ssa/bool-15.c: New test. * gcc.dg/tree-ssa/phi-opt-33.c: New test. * gcc.dg/tree-ssa/20030709-2.c: Update testcase so `a ? -1 : 0` is not used to hit the match pattern. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/100798] a?~t:t and (-(!!a))^t don't produce the same assembly code 2021-05-27 10:39 [Bug middle-end/100798] New: a?~t:t and (-(!!a))^t don't produce the same assembly code pinskia at gcc dot gnu.org ` (3 preceding siblings ...) 2023-08-09 19:22 ` cvs-commit at gcc dot gnu.org @ 2023-08-09 19:27 ` pinskia at gcc dot gnu.org 4 siblings, 0 replies; 6+ messages in thread From: pinskia at gcc dot gnu.org @ 2023-08-09 19:27 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100798 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |FIXED Status|ASSIGNED |RESOLVED Target Milestone|--- |14.0 --- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Fixed. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-08-09 19:27 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-05-27 10:39 [Bug middle-end/100798] New: a?~t:t and (-(!!a))^t don't produce the same assembly code pinskia at gcc dot gnu.org 2023-05-20 2:25 ` [Bug middle-end/100798] " pinskia at gcc dot gnu.org 2023-08-07 19:04 ` pinskia at gcc dot gnu.org 2023-08-08 0:55 ` pinskia at gcc dot gnu.org 2023-08-09 19:22 ` cvs-commit at gcc dot gnu.org 2023-08-09 19:27 ` pinskia at gcc dot gnu.org
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).