B^HDEAD code generation (AMD64)
LIU Hao
lh_mouse@126.com
Mon Jan 9 12:17:04 GMT 2023
在 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 840 bytes
Desc: OpenPGP digital signature
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/20230109/381fe0c9/attachment.sig>
More information about the Gcc
mailing list