https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91720
Bug ID: 91720
Summary: [10 Regression] wrong code with -Og
-fno-forward-propagate -frerun-cse-after-loop
-fno-tree-fre
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: zsojka at seznam dot cz
Target Milestone: ---
Host: x86_64-pc-linux-gnu
Target: riscv64-unknown-linux-gnu
Created attachment 46860
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46860&action=edit
reduced testcase
Compiler output:
$ riscv64-unknown-linux-gnu-gcc -Og -fno-forward-propagate
-frerun-cse-after-loop -fno-tree-fre testcase.c -static
$ ./a.out
Aborted
The problem seems to be the -128 constant, which should be +128 instead (as
gcc-9 generates); this fixes the assembly:
--- testcase.s.BAD 2019-09-10 12:55:09.329946806 +0200
+++ testcase.s.OK 2019-09-10 12:55:36.739946702 +0200
@@ -52,7 +52,7 @@
sh a5,8(sp) # MEM <short unsigned int> [(char *
{ref-all})&a], MEM <short unsigned int> [(char * {ref-all})&d]
# testcase.c:16: b = e;
lui a4,%hi(b) # tmp93,
- li a5,-128 # iftmp.0_7,
+ li a5,+128 # iftmp.0_7,
srliw a5,a5,1 #, tmp101, iftmp.0_7
sw a5,%lo(b)(a4) # tmp101, b
# testcase.c:17: if (b != 0x40)
$ riscv64-unknown-linux-gnu-gcc -v
Using built-in specs.
COLLECT_GCC=/repo/gcc-trunk/binary-latest-riscv64/bin/riscv64-unknown-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/repo/gcc-trunk/binary-trunk-275578-checking-yes-rtl-df-extra-riscv64/bin/../libexec/gcc/riscv64-unknown-linux-gnu/10.0.0/lto-wrapper
Target: riscv64-unknown-linux-gnu
Configured with: /repo/gcc-trunk//configure --enable-languages=c,c++
--enable-valgrind-annotations --disable-nls --enable-checking=yes,rtl,df,extra
--with-cloog --with-ppl --with-isl
--with-sysroot=/usr/riscv64-unknown-linux-gnu --build=x86_64-pc-linux-gnu
--host=x86_64-pc-linux-gnu --target=riscv64-unknown-linux-gnu
--with-ld=/usr/bin/riscv64-unknown-linux-gnu-ld
--with-as=/usr/bin/riscv64-unknown-linux-gnu-as --disable-multilib
--disable-libstdcxx-pch
--prefix=/repo/gcc-trunk//binary-trunk-275578-checking-yes-rtl-df-extra-riscv64
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.0.0 20190910 (experimental) (GCC)