public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "daniel.blaukopf at oracle dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/57967] Incorrect code generated on ARM with -fexpensive-optimizations Date: Wed, 24 Jul 2013 11:16:00 -0000 [thread overview] Message-ID: <bug-57967-4-EqPqbQqUBI@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-57967-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57967 --- Comment #2 from Daniel Blaukopf <daniel.blaukopf at oracle dot com> --- This code: int f1(int x0, int y0, int z0, int x1, int y1, int z1) { int xx = ((x0 << 16) + (x1 - x0) * 0x1234 + 0x8000) >> 16; int yy = ((y0 << 16) + (y1 - y0) * 0x2345 + 0x8000) >> 16; int zz = ((z0 << 16) + (z1 - z0) * 0x3456 + 0x8000) >> 16; return (xx << 16) | (yy << 8) | zz; } Compiles (incorrectly) to: f1: @ args = 8, pretend = 0, frame = 0 @ frame_needed = 0, uses_anonymous_args = 0 @ link register save eliminated. ldr r0, [sp, #4] subs r0, r0, r2 movw r3, #13398 mul r0, r3, r0 add r2, r0, r2, lsl #16 ldr r3, [sp, #0] subs r3, r3, r1 movw r0, #9029 mul r3, r0, r3 add r1, r3, r1, lsl #16 add r1, r1, #32768 asr r1, r1, #16 lsl r1, r1, #8 add r0, r2, #32768 orr r0, r1, r0, asr #16 bx lr This almost identical code: int f2(int x0, int x1, int y0, int y1, int z0, int z1) { int xx = ((x0 << 16) + (x1 - x0) * 0x1234 + 0x8000) >> 16; int yy = ((y0 << 16) + (y1 - y0) * 0x2345 + 0x8000) >> 16; int zz = ((z0 << 16) + (z1 - z0) * 0x3456 + 0x8000) >> 16; return (xx << 16) | (yy << 8) | zz; } Compiles (correctly) to: f2: @ args = 8, pretend = 0, frame = 0 @ frame_needed = 0, uses_anonymous_args = 0 @ link register save eliminated. push {r4, r5} ldr r4, [sp, #8] subs r3, r3, r2 movw r5, #9029 mul r3, r5, r3 add r2, r3, r2, lsl #16 add r2, r2, #32768 asr r2, r2, #16 subs r1, r1, r0 movw r3, #4660 mul r1, r3, r1 add r0, r1, r0, lsl #16 add r0, r0, #32768 asr r0, r0, #16 lsl r0, r0, #16 orr r2, r0, r2, lsl #8 ldr r0, [sp, #12] subs r0, r0, r4 movw r3, #13398 mul r0, r3, r0 add r4, r0, r4, lsl #16 add r0, r4, #32768 orr r0, r2, r0, asr #16 pop {r4, r5} bx lr
next prev parent reply other threads:[~2013-07-24 11:16 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2013-07-24 11:08 [Bug rtl-optimization/57967] New: " daniel.blaukopf at oracle dot com 2013-07-24 11:09 ` [Bug rtl-optimization/57967] " daniel.blaukopf at oracle dot com 2013-07-24 11:16 ` daniel.blaukopf at oracle dot com [this message] 2013-07-24 15:45 ` [Bug rtl-optimization/57967] [4.7 regresssion] " rearnsha at gcc dot gnu.org 2013-07-25 13:59 ` mikpe at it dot uu.se 2013-08-28 9:22 ` rguenth at gcc dot gnu.org 2014-06-12 13:52 ` rguenth 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-57967-4-EqPqbQqUBI@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).