From: Cody Rigney <codyrigney92@gmail.com>
To: Andrew Haley <aph@redhat.com>
Cc: gcc-help@gcc.gnu.org
Subject: Re: Compiler optimizing variables in inline assembly
Date: Fri, 21 Feb 2014 14:06:00 -0000 [thread overview]
Message-ID: <CA+1=iYbAnZGdaVoFVuJnm+oQSCiHPTUOBmy8f7RycSAvu92i+w@mail.gmail.com> (raw)
In-Reply-To: <5307221E.8070409@redhat.com>
I added all the registers and "memory" to clobber and it worked!
Since I think it's more efficient to specify which memory is changing,
I'm going to give the "=m" (*a) a shot. So even though you
dereference the pointer, gcc will know the length of the memory(say 2
bytes) that changes? Or do you have to specify each index of the
memory(e.g. char a[2]; ..... asm ... "=m" (*a), "=m" (*(a+1)))?
On Fri, Feb 21, 2014 at 4:53 AM, Andrew Haley <aph@redhat.com> wrote:
> On 02/20/2014 07:29 PM, Cody Rigney wrote:
>> On Thu, Feb 20, 2014 at 4:14 AM, Andrew Haley <aph@redhat.com> wrote:
>>> Hi,
>>>
>>> On 02/19/2014 07:04 PM, Cody Rigney wrote:
>>>> I'm trying to add NEON optimizations to OpenCV's LK optical flow. See
>>>> link below.
>>>> https://github.com/Itseez/opencv/blob/2.4/modules/video/src/lkpyramid.cpp
>>>>
>>>> The gcc version could vary since this is an open source project, but
>>>> the one I'm currently using is 4.8.1. The target architecture is ARMv7
>>>> w/ NEON. The processor I'm testing on is an ARM
>>>> Cortex-A15(big.LITTLE).
>>>>
>>>> The problem is, in release mode (where optimizations are set) it does
>>>> not work properly. However, in debug mode, it works fine. I tracked
>>>> down a specific variable(FLT_SCALE) that was being optimized out and
>>>> made it volatile and that part worked fine after that. However, I'm
>>>> still having incorrect behavior from some other optimization.
>>>
>>> Forget about using volatile here. That's just wrong.
>>>
>>> You have to mark your inputs, outputs, and clobbers correctly.
>>>
>> That makes sense. In this case, the input parameters are actually
>> memory addresses. So how would I do an output or clobber that would
>> tell the compiler that the memory at those addresses will change?
>
> You can use a memory operand as an output, as in "=m"(*a) or simply
> add "memory" to the clobber list. And you must add all clobbered
> registers to the clobber list. Then it should work.
>
> Andrew.
>
>
next prev parent reply other threads:[~2014-02-21 14:06 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-19 19:05 Cody Rigney
2014-02-20 9:14 ` Andrew Haley
2014-02-20 19:30 ` Cody Rigney
2014-02-21 9:53 ` Andrew Haley
2014-02-21 14:06 ` Cody Rigney [this message]
2014-02-21 15:02 ` Andrew Haley
2014-02-21 15:20 ` Cody Rigney
2014-02-27 13:18 ` Cody Rigney
2014-02-27 14:03 ` Andrew Haley
2014-02-27 18:34 ` Cody Rigney
2014-02-21 9:54 ` David Brown
2014-02-21 9:55 ` David Brown
2014-02-20 9:54 ` David Brown
2014-02-20 19:39 ` Cody Rigney
2014-02-21 10:15 ` David Brown
2014-02-21 14:11 ` Cody Rigney
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='CA+1=iYbAnZGdaVoFVuJnm+oQSCiHPTUOBmy8f7RycSAvu92i+w@mail.gmail.com' \
--to=codyrigney92@gmail.com \
--cc=aph@redhat.com \
--cc=gcc-help@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: link
Be 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).