https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63390
--- Comment #1 from Oleg Endo olegendo at gcc dot gnu.org ---
Adding a loop to the example above shows that function address loads are
hoisted already out of loops, but constant loads are not.
void foo (unsigned int, int);
void test (unsigned int* x, int c)
{
while (--c)
if (__builtin_expect ((*x 1) != 0, 1))
foo (*x 1, 123456);
}
results in:
mov.l r8,@-r15
mov r5,r8
mov.l r9,@-r15
mov r4,r9
mov.l r10,@-r15
mov.l .L11,r10function address load
sts.l pr,@-r15
.L2:
dt r8
bt .L10
.align 2
.L4:
mov.l @r9,r4 constant load
shlrr4
tst r4,r4
bt .L2
mov.l .L12,r5
jsr @r10
nop
dt r8
bf .L4
.L10:
lds.l @r15+,pr
mov.l @r15+,r10
mov.l @r15+,r9
rts
mov.l @r15+,r8