From: LIU Hao <lh_mouse@126.com>
To: Thomas Koenig <tkoenig@netcologne.de>,
Stefan Kanthak <stefan.kanthak@nexgo.de>,
gcc@gnu.org
Subject: Re: B^HDEAD code generation (AMD64)
Date: Mon, 9 Jan 2023 20:17:04 +0800 [thread overview]
Message-ID: <46a96829-3a80-5584-52b1-f57e147714a4@126.com> (raw)
In-Reply-To: <5e02f939-7356-a43f-d570-6e270fb6ad8b@netcologne.de>
[-- Attachment #1.1: Type: text/plain, Size: 966 bytes --]
在 2023/1/9 19:48, Thomas Koenig via Gcc 写道:
> On 09.01.23 12:35, Stefan Kanthak wrote:
>> 20 superfluous instructions of the total 102 instructions!
>
> The proper place for bug reports is https://gcc.gnu.org/bugzilla/ .
> Feel free to submit these cases there.
Created https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108341, although I'm not sure whether it's
related to this issue.
Given
```
extern int r;
int
bz(int value)
{
r = __builtin_ctz(value);
return value != 0; // always true
}
```
`value` is passed to `__builtin_ctz` and GCC should assume it can't be zero, otherwise the behavior
is undefined. However GCC fails to optimize it and produces:
```
bz:
endbr64
xor eax, eax
rep bsf eax, edi
mov DWORD PTR r[rip], eax
xor eax, eax
test edi, edi
setne al
ret
```
--
Best regards,
LIU Hao
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]
next prev parent reply other threads:[~2023-01-09 12:17 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-09 11:35 Stefan Kanthak
2023-01-09 11:48 ` Thomas Koenig
2023-01-09 12:17 ` LIU Hao [this message]
2023-01-10 0:34 ` Stefan Kanthak
2023-01-10 3:22 ` Andrew Pinski
2023-01-10 7:12 ` Gabriel Ravier
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=46a96829-3a80-5584-52b1-f57e147714a4@126.com \
--to=lh_mouse@126.com \
--cc=gcc@gnu.org \
--cc=stefan.kanthak@nexgo.de \
--cc=tkoenig@netcologne.de \
/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).