https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125557
--- Comment #13 from ktkachov at gcc dot gnu.org ---
Ok, so with the patches that landed we're in better shape now. My original
reduced case from Snappy now if-converts well at -O3 -fno-split-paths, but the
full Snappy usecase still has the bad branch. The larger representative case
from Snappy is now:
#include <stddef.h>
#include <stdint.h>
extern const int16_t kLengthMinusOffset[256];
static inline uint32_t ExtractOffset (uint32_t val, size_t tag_type)
{
const uint64_t M=0x0000FFFF00FF0000ull; return val &
(uint32_t)((M>>(tag_type*16))&0xFFFF);
}
ptrdiff_t
f (const uint8_t *ip, size_t tag, const uint8_t *end, ptrdiff_t op){
do {
size_t tt = tag & 3;
if (tt==0)
{
size_t n=(tag>>2)+1;
tag=ip[n];
ip+=n+1;
} else {
tag=ip[tt];
ip+=tt+1;
}
const uint64_t M=0x0000FFFF00FF0000ull;
op += (ptrdiff_t)((M>>(tt*16))&0xFFFF);
} while (ip<end);
return op;
}
We can still see the branchy GCC codegen at https://godbolt.org/z/fqn78ddqa
I guess -fsplit-paths aside (I assume we'll remove it, I can help with that) we
still need PR125792 ?