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

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).