Re: Optimization breaks inline asm code w/ptrs

2017-08-18 Thread Eric Gallager
On 8/14/17, Alan Modra wrote: > On Sun, Aug 13, 2017 at 10:25:14PM +0930, Alan Modra wrote: >> On Sun, Aug 13, 2017 at 03:35:15AM -0700, David Wohlferd wrote: >> > Using "m"(*pStr) as an (unused) input parameter has no effect. >> >> Use "m" (*(const void *)pStr) and ignore the warning, or use >> "

Re: Optimization breaks inline asm code w/ptrs

2017-08-17 Thread Alan Modra
On Thu, Aug 17, 2017 at 04:27:12PM +0200, Michael Matz wrote: > Hi, > > On Mon, 14 Aug 2017, Alan Modra wrote: > > > I've opened https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81845 to track > > the lack of documentation. > > You mean like in this paragraph discussing memory clobbers and uses in

Re: Optimization breaks inline asm code w/ptrs

2017-08-17 Thread Michael Matz
Hi, On Mon, 14 Aug 2017, Alan Modra wrote: > I've opened https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81845 to track > the lack of documentation. You mean like in this paragraph discussing memory clobbers and uses in extended asms that we have since 2004? : If your assembler

Re: Optimization breaks inline asm code w/ptrs

2017-08-16 Thread Alan Modra
On Tue, Aug 15, 2017 at 03:09:15PM +0800, Liu Hao wrote: > On 2017/8/14 20:41, Alan Modra wrote: > >On Sun, Aug 13, 2017 at 10:25:14PM +0930, Alan Modra wrote: > >>On Sun, Aug 13, 2017 at 03:35:15AM -0700, David Wohlferd wrote: > >>>Using "m"(*pStr) as an (unused) input parameter has no effect. > >

Re: Optimization breaks inline asm code w/ptrs

2017-08-15 Thread Liu Hao
On 2017/8/14 20:41, Alan Modra wrote: On Sun, Aug 13, 2017 at 10:25:14PM +0930, Alan Modra wrote: On Sun, Aug 13, 2017 at 03:35:15AM -0700, David Wohlferd wrote: Using "m"(*pStr) as an (unused) input parameter has no effect. Use "m" (*(const void *)pStr) and ignore the warning, or use "m" (*(

Re: Optimization breaks inline asm code w/ptrs

2017-08-14 Thread Alan Modra
On Sun, Aug 13, 2017 at 10:25:14PM +0930, Alan Modra wrote: > On Sun, Aug 13, 2017 at 03:35:15AM -0700, David Wohlferd wrote: > > Using "m"(*pStr) as an (unused) input parameter has no effect. > > Use "m" (*(const void *)pStr) and ignore the warning, or use > "m" (*(const struct {char a; char x[];

Re: Optimization breaks inline asm code w/ptrs

2017-08-13 Thread Alan Modra
On Sun, Aug 13, 2017 at 03:35:15AM -0700, David Wohlferd wrote: > Using "m"(*pStr) as an (unused) input parameter has no effect. Use "m" (*(const void *)pStr) and ignore the warning, or use "m" (*(const struct {char a; char x[];} *) pStr). The issue is one of letting gcc know what memory is acces

Re: Optimization breaks inline asm code w/ptrs

2017-08-13 Thread David Wohlferd
On 8/12/2017 10:14 PM, Andrew Pinski wrote: On Sat, Aug 12, 2017 at 10:08 PM, Andrew Pinski wrote: On Sat, Aug 12, 2017 at 9:21 PM, David Wohlferd wrote: Environment: gcc 6.1 compiling for 64bit i386 optimizations: -O2 Consider this simple bit of code (from https://stackoverflow.com/a/456560

Re: Optimization breaks inline asm code w/ptrs

2017-08-12 Thread Andrew Pinski
On Sat, Aug 12, 2017 at 9:21 PM, David Wohlferd wrote: > Environment: > gcc 6.1 > compiling for 64bit i386 > optimizations: -O2 > > Consider this simple bit of code (from > https://stackoverflow.com/a/45656087/2189500): > > #include > > int getStringLength(const char *pStr){ > > int len; > >

Re: Optimization breaks inline asm code w/ptrs

2017-08-12 Thread Andrew Pinski
On Sat, Aug 12, 2017 at 10:08 PM, Andrew Pinski wrote: > On Sat, Aug 12, 2017 at 9:21 PM, David Wohlferd > wrote: >> Environment: >> gcc 6.1 >> compiling for 64bit i386 >> optimizations: -O2 >> >> Consider this simple bit of code (from >> https://stackoverflow.com/a/45656087/2189500): >> >> #inc

Optimization breaks inline asm code w/ptrs

2017-08-12 Thread David Wohlferd
Environment: gcc 6.1 compiling for 64bit i386 optimizations: -O2 Consider this simple bit of code (from https://stackoverflow.com/a/45656087/2189500): #include int getStringLength(const char *pStr){ int len; __asm__ ( "repne scasb\n\t" "not %%ecx\n\t" "dec