public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "thaines.astro at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/68000] Suboptimal ternary operator codegen
Date: Sun, 18 Oct 2015 20:38:00 -0000 [thread overview]
Message-ID: <bug-68000-4-FvxPrqTMHV@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-68000-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68000
--- Comment #3 from Tim Haines <thaines.astro at gmail dot com> ---
(In reply to Andrew Pinski from comment #1)
> Note I think the trunk already has improved code generation.
Here is the codegen from the latest trunk build using the same options as
before.
foo_manual_hoist:
movzx eax, BYTE PTR [rdi]
mov edx, 0
inc eax
cmp al, BYTE PTR [rdi+1]
cmove eax, edx
ret
foo:
movzx edx, BYTE PTR [rdi]
movzx ecx, BYTE PTR [rdi+1]
mov eax, edx
inc edx
cmp edx, ecx
je .L6
inc eax
ret
.L6:
xor eax, eax
ret
foo_if:
movzx eax, BYTE PTR [rdi]
mov edx, 0
inc eax
cmp al, BYTE PTR [rdi+1]
cmove eax, edx
ret
Changing from a cmove to a cmp/jmp doesn't change the instruction latency
(although I couldn't find the latency for je on intel. I assume it's 1 like on
AMD), but now the branch predictor will be invoked- bringing possible pipeline
hazards. I don't mean to be overly critical, but I wouldn't consider this to be
an improvement to the previous code- especially since the other two versions of
the function use cmove. As Marc noted, we are still missing CSE here.
NB: The structure offsets are different here because the assembly I originally
posted was poorly anonymized by me. Mea culpa!
next prev parent reply other threads:[~2015-10-18 20:38 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <bug-68000-4@http.gcc.gnu.org/bugzilla/>
2015-10-17 6:54 ` pinskia at gcc dot gnu.org
2015-10-17 8:34 ` glisse at gcc dot gnu.org
2015-10-18 20:38 ` thaines.astro at gmail dot com [this message]
2015-10-19 5:17 ` pinskia at gcc dot gnu.org
2021-06-03 4:11 ` 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-68000-4-FvxPrqTMHV@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).