public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "wumingchuan1992 at foxmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug target/109254] New: Bug in gcc (13.0.1) support for ARM SVE, which randomly modifies the prediction register Date: Thu, 23 Mar 2023 03:14:28 +0000 [thread overview] Message-ID: <bug-109254-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109254 Bug ID: 109254 Summary: Bug in gcc (13.0.1) support for ARM SVE, which randomly modifies the prediction register Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: wumingchuan1992 at foxmail dot com Target Milestone: --- func_demo.c #include <stdio.h> #include <arm_sve.h> svfloat32_t func_demo(svfloat32_t x, svfloat32_t y, svbool_t pg) { svfloat32_t z = svadd_f32_x(pg, x, svdup_f32(0x1.800fep19f)); svbool_t cmp = svcmplt_f32(pg, z, svdup_f32(0.0f)); svfloat32_t zM1 = svsub_f32_x(pg, z, svdup_n_f32(1.0f)); z = svsel_f32(cmp, zM1, z); svfloat32_t sum = svadd_f32_x(pg, z, y); return sum; } Run gcc(10.3.0 and 13.0.1 20230314) with the following command: $ gcc -std=c99 -O2 -funroll-loops -march=armv8.3-a+fp+sve -o func_demo.o -c func_demo.c After objdump func_demo.o, the result is as follows: 0000000000000000 <func_demo>: 0: 90000000 adrp x0, 0 <func_demo> 4: 2518e3e1 ptrue p1.b 8: 91000001 add x1, x0, #0x0 c: 8540c422 ld1rw {z2.s}, p1/z, [x1] 10: 65808002 fadd z2.s, p0/m, z2.s, z0.s 14: 65912040 fcmlt p0.s, p0/z, z2.s, #0.0 18: 0420bc43 movprfx z3, z2 1c: 65998023 fsub z3.s, p0/m, z3.s, #1.0 20: 05a2c060 sel z0.s, p0, z3.s, z2.s 24: 65808020 fadd z0.s, p0/m, z0.s, z1.s 28: d65f03c0 ret In the compilation of the 14 lines, the fcmlt operation covers the value of the p0 register, resulting in subsequent fsubs and fadd using the wrong prediction register. This results in an error in the program result. For comparison, use llvm for compilation: clang -std=c99 -O2 -funroll-loops -march=armv8.3-a+fp+sve -o func_demo1.o -c func_demo.c the result is as follows: 0000000000000000 <func_demo>: 0: 5280fe08 mov w8, #0x7f0 // #2032 4: 72a92808 movk w8, #0x4940, lsl #16 8: 05a03902 mov z2.s, w8 c: 65808040 fadd z0.s, p0/m, z0.s, z2.s 10: 04603002 mov z2.d, z0.d 14: 65912001 fcmlt p1.s, p0/z, z0.s, #0.0 18: 65998022 fsub z2.s, p0/m, z2.s, #1.0 1c: 05a0c440 mov z0.s, p1/m, z2.s 20: 65808020 fadd z0.s, p0/m, z0.s, z1.s 24: d65f03c0 ret Line 14 is correct. Any suggestions to proceed?
next reply other threads:[~2023-03-23 3:14 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-03-23 3:14 wumingchuan1992 at foxmail dot com [this message] 2023-03-23 3:23 ` [Bug target/109254] " pinskia at gcc dot gnu.org 2023-03-23 14:43 ` jakub at gcc dot gnu.org 2023-03-23 16:08 ` jakub at gcc dot gnu.org 2023-03-23 17:13 ` jakub at gcc dot gnu.org 2023-03-24 12:24 ` jakub at gcc dot gnu.org 2023-03-27 7:53 ` pinskia at gcc dot gnu.org 2023-04-01 6:58 ` cvs-commit at gcc dot gnu.org 2023-04-03 13:18 ` jakub at gcc dot gnu.org 2024-02-28 6:48 ` pinskia at gcc dot gnu.org
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-109254-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).