From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14394 invoked by alias); 21 Feb 2014 14:06:07 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 14382 invoked by uid 89); 21 Feb 2014 14:06:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL,BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-pd0-f181.google.com Received: from mail-pd0-f181.google.com (HELO mail-pd0-f181.google.com) (209.85.192.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Fri, 21 Feb 2014 14:06:05 +0000 Received: by mail-pd0-f181.google.com with SMTP id y13so823918pdi.40 for ; Fri, 21 Feb 2014 06:06:03 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.68.237.133 with SMTP id vc5mr9388042pbc.92.1392991563690; Fri, 21 Feb 2014 06:06:03 -0800 (PST) Received: by 10.70.18.193 with HTTP; Fri, 21 Feb 2014 06:06:03 -0800 (PST) In-Reply-To: <5307221E.8070409@redhat.com> References: <5305C77D.3090807@redhat.com> <5307221E.8070409@redhat.com> Date: Fri, 21 Feb 2014 14:06:00 -0000 Message-ID: Subject: Re: Compiler optimizing variables in inline assembly From: Cody Rigney To: Andrew Haley Cc: gcc-help@gcc.gnu.org Content-Type: text/plain; charset=ISO-8859-1 X-SW-Source: 2014-02/txt/msg00136.txt.bz2 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 wrote: > On 02/20/2014 07:29 PM, Cody Rigney wrote: >> On Thu, Feb 20, 2014 at 4:14 AM, Andrew Haley 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. > >