public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "ddiculoiu at dspace dot de" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug target/97040] New: incorrect fused multiply add/subtract instruction generated from C code Date: Sun, 13 Sep 2020 17:14:53 +0000 [thread overview] Message-ID: <bug-97040-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97040 Bug ID: 97040 Summary: incorrect fused multiply add/subtract instruction generated from C code Product: gcc Version: 8.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: ddiculoiu at dspace dot de Target Milestone: --- Target: v850-elf Consider the following simple code: __attribute__ ((noinline)) float func_a(float x, float y, float z) { return (x-y*z); } __attribute__ ((noinline)) float func_b(float x, float y, float z) { return (-x-y*z); } volatile float x = 5.0,y = 2.0,z = 1.0; int main() { volatile float c = func_a(x,y,z); volatile float d = func_b(x,y,z); return 0; } compiled with: v850-elf-gcc test.c -mrh850-abi -mv850e3v5 -nostdlib --entry=0 -O2 The gcc generates the following assembly code for the 'func_a' and 'func_b': 00100000 <_func_a>: 100000: 06 50 mov r6, r10 100002: e7 47 e4 54 fnmaf.s r7, r8, r10 100006: 7f 00 jmp [lp] 00100008 <_func_b>: 100008: 06 50 mov r6, r10 10000a: e7 47 e6 54 fnmsf.s r7, r8, r10 10000e: 7f 00 jmp [lp] In my opinion the 2 instructions 'fnmaf.s' and 'fnmsf.s' are exchanged in the 2 functions. The funtion 'func_a' must contain the 'fnmsf.s' and the 'func_b' the 'fnmaf.s' instruction. Can someone confirm my observations? Thanks. P.S. I did a test with older (gcc 4.9.0) and latest (gcc 10.2.0) gcc. Both have the same problem. I think the bug is from the first release where the fused multiply and add/subtraction were added and nobody detected it yet. When I compile the same code with Green Hills Compiler I got the correct assembly instruction for 'func_a' and the 'func_b' uses negated value for x and the 'fnmsf.s' instruction instead of the 'fnmaf.s' one, but the result is correct: 00001000 <_func_a>: 1000: 06 50 mov r6, r10 1002: e7 47 e6 54 fnmsf.s r7, r8, r10 1006: 7f 00 jmp [lp] 00001010 <_func_b>: 1010: e1 37 48 54 negf.s r6, r10 1014: e7 47 e6 54 fnmsf.s r7, r8, r10 1018: 7f 00 jmp [lp]
next reply other threads:[~2020-09-13 17:14 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-09-13 17:14 ddiculoiu at dspace dot de [this message] 2022-02-06 18:20 ` [Bug target/97040] " law at gcc dot gnu.org 2022-02-09 19:06 ` law at gcc dot gnu.org 2022-02-09 19:13 ` cvs-commit at gcc dot gnu.org 2022-02-11 16:58 ` law 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-97040-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).