https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122919
--- Comment #4 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
Here's another test case, which has two full divisions:
typedef struct {
long spx;
} stackpointers;
stackpointers *gforth_engine2_in_SPs;
long gforth_engine2_spc;
void gforth_engine2() {
stackpointers *SPs = gforth_engine2_in_SPs;
long *sp = &SPs->spx;
long spb, u3;
void *symbols[] = {&&K_ten_u_slash_mod, &&K__p343, &&K__p344,
&&J_ten_u_slash_mod, &&J__p343, &&J__p344,
&&after_last, &&before_goto, &&after_goto,
&&H_ten_u_slash_mod, &&H__p343, &&H__p344};
spb = sp[1];
H_ten_u_slash_mod:
K_ten_u_slash_mod:
J_ten_u_slash_mod:
H__p343:
K__p343:
J__p343:
H__p344:
unsigned long u1;
unsigned u4;
u1 = spb;
u4 = u1 / 10;
u3 = u1 % 10;
spb = u3;
gforth_engine2_spc = u4;
K__p344:
J__p344:
after_last:
before_goto:
after_goto:
goto * 0;
}
Assembly is
gforth_engine2:
.LFB0:
.cfi_startproc
movq gforth_engine2_in_SPs(%rip), %rax
movq 8(%rax), %rax
.L8:
movq %rax, %rsi
movabsq $-3689348814741910323, %rax
mulq %rsi
movq %rdx, %rax
shrq $3, %rdx
shrq $3, %rax
andl $4294967295, %edx
leaq (%rax,%rax,4), %rcx
movq %rdx, gforth_engine2_spc(%rip)
movq %rsi, %rax
xorl %edx, %edx
addq %rcx, %rcx
subq %rcx, %rax
jmp *%rdx
.L13:
xorl %edx, %edx
jmp *%rdx
.L12:
xorl %edx, %edx
jmp *%rdx
.L11:
xorl %edx, %edx
jmp *%rdx
.L10:
xorl %edx, %edx
jmp *%rdx
.L9:
xorl %edx, %edx
jmp *%rdx
.L7:
jmp .L8
[...]