https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125517
Bug ID: 125517
Summary: Wrong code for __builtin_bitreverse128
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: kristerw at gcc dot gnu.org
Blocks: 118443
Target Milestone: ---
The ccp1 pass is miscompiling the functions below (taken from
gcc.dg/builtin-bitreverse-8.c) when compiling for x86_64 with -O1:
#define BS(X) __builtin_bitreverse128 (X)
unsigned __int128
foo2 (unsigned __int128 a)
{
return BS (BS (a) & 0xA0000A0000ULL);
}
unsigned __int128
foo3 (unsigned __int128 a)
{
return BS (BS (a) | 0xA0000A0000ULL);
}
unsigned __int128
foo4 (unsigned __int128 a)
{
return BS (BS (a) ^ 0xA0000A0000ULL);
}
The function foo2 is incorrectly optimized to `return 0`, while the other two
are incorrectly optimized to `return a`.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118443
[Bug 118443] [Meta bug] Bugs triggered by and blocking more smtgcc testing