https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90594
Hsiao-Hui Chiu <hailey.chiu at sifive dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |hailey.chiu at sifive dot com
--- Comment #6 from Hsiao-Hui Chiu <hailey.chiu at sifive dot com> ---
Hi,
I got the same issue that my program is compiled with gcc-10.1 with riscv. Here
is my code,
C source:
void foo()
{
static long *a;
static int i;
static int sum;
sum = 0;
for ( i = 1 ; i < n ; i++)
{
sum += (*a--);
}
}
Compiling with riscv-gcc-10.1, with -Os,
riscv-gcc-10.1/riscv64-unknown-elf-gcc -Os -march=rv32imac -mabi=ilp32 -S -o
foo.s foo.c
Asm:
foo:
...skip...
.L6:
addi a7,a7,1
bgt a5,a7,.L7
li a4,0
ble a5,zero,.L9
li a4,-4
mul a4,a5,a4
addi a4,a4,4 #a = -4*n + 4
.L9:
add a4,a0,a4
bgt a5,zero,.L10
li a5,1
.L10:
beq t3,zero,.L5
sw a4,%lo(a.1)(a1)
sw a6,%lo(sum.3)(a2)
sw a5,%lo(i.2)(a3)
.L5:
ret
.L7:
lw a4,0(t1)
li t3,1
addi t1,t1,-4 #a--
add a6,a6,a4
j .L6
That .L6 segment is totally redundant. By inspecting the gcc trace, this is
happening at SCCP pass as this reported bug described. But, when I compiled the
bad_popcount function, I didn't see any redundant code emitted.
According previous comments, I know this is under fixing. I am just wondering
if there is anything updated between last May to now?
Thanks.