public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "mumuxi_ll at outlook dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/113715] New: RISC-V: If the Zcmp is enabled, the a0 register operates abnormally when the program returns Date: Fri, 02 Feb 2024 08:51:44 +0000 [thread overview] Message-ID: <bug-113715-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113715 Bug ID: 113715 Summary: RISC-V: If the Zcmp is enabled, the a0 register operates abnormally when the program returns Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: mumuxi_ll at outlook dot com Target Milestone: --- When compiling the following test.c code with the options -march=rv32ima_zca_zcb_zcmp_zcmt -mabi=ilp32 -Os, a bug appears when gcc enables zcmp. In the disassembly dump.txt, it can be observed that when executing the bne instruction in test_err, a0 is not set to 0 as the function return value. Source code: void test_1(int onoff) { for (volatile int i = 0; i < 100; i ++) { } } int test_err(void *param, int mode, int *saveAddr) { if (mode == 2) { test_1(1); } return 0; } int main() { int ret = test_err((void *)0x123456, 3, (int *)0x123456); for (volatile int i = ret; i < 100; i ++) { ret = i * i; } return ret; } GCC ASM: test_1: addi sp,sp,-16 sw zero,12(sp) li a4,99 .L2: lw a5,12(sp) ble a5,a4,.L3 addi sp,sp,16 jr ra .L3: lw a5,12(sp) addi a5,a5,1 sw a5,12(sp) j .L2 test_err: li a5,2 bne a1,a5,.L8 li a0,1 cm.push {ra}, -16 call test_1 cm.popretz {ra}, 16 .L8: ret main: addi sp,sp,-16 sw zero,12(sp) li a0,0 li a3,99 .L12: lw a5,12(sp) ble a5,a3,.L13 addi sp,sp,16 jr ra .L13: lw a0,12(sp) lw a4,12(sp) mul a0,a0,a4 lw a4,12(sp) addi a4,a4,1 sw a4,12(sp) j .L12
next reply other threads:[~2024-02-02 8:51 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-02-02 8:51 mumuxi_ll at outlook dot com [this message] 2024-02-06 3:16 ` [Bug target/113715] " fanghuaqi at vip dot qq.com 2024-02-06 3:36 ` pinskia at gcc dot gnu.org 2024-02-08 3:11 ` fanghuaqi at vip dot qq.com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-113715-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).