[Bug inline-asm/37195] different variables get the same overlapping memory address in inline assembly

2010-04-30 Thread jdemeyer at cage dot ugent dot be


--- Comment #8 from jdemeyer at cage dot ugent dot be  2010-04-30 07:24 
---
On first sight, it looks fixed in gcc 4.6.0 SVN.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37195



[Bug inline-asm/41294] New: =rm constraints give overlapping memory addresses

2009-09-07 Thread jdemeyer at cage dot ugent dot be
In some cases in inline asm, an output parameter with no-clobber =rm
constraint gets the same address as an input parameter, even when they refer to
two different C variables.  This seems to happen when the following conditions
are satisfied:

* The variables involved appear only in inline asm (as the output of one asm
statement and the input of a second).
* The output constraint is =rm (=m works correctly).
* There are too many clobbered variables forcing some of the output parameters
into memory.

The attached testcase works for i386, x86_64, powerpc and powerpc64.  For other
targets, change the clobber list to include as much registers as possible.
Compile with gcc -O1 -save-temps -c -o bug.o bug.c

Tested with gcc -v:
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc/configure CC=/usr/bin/gcc-4.3.4
--prefix=/home/jdemeyer/local --enable-checking=release
Thread model: posix
gcc version 4.5.0 20090904 (experimental) (GCC)


-- 
   Summary: =rm constraints give overlapping memory addresses
   Product: gcc
   Version: 4.5.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: inline-asm
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jdemeyer at cage dot ugent dot be


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41294



[Bug inline-asm/41294] =rm constraints give overlapping memory addresses

2009-09-07 Thread jdemeyer at cage dot ugent dot be


--- Comment #1 from jdemeyer at cage dot ugent dot be  2009-09-07 10:49 
---
Created an attachment (id=18528)
 -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=18528action=view)
Testcase


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41294



[Bug inline-asm/41294] =rm constraints give overlapping memory addresses

2009-09-07 Thread jdemeyer at cage dot ugent dot be


--- Comment #3 from jdemeyer at cage dot ugent dot be  2009-09-07 19:30 
---
(In reply to comment #2)
 I think you need to mark both alternatives early-clobber, not only the 
 register
 one.  Thus =rm at least according to the manual.

That doesn't seem to change anything.  It looks to me like the parser only
checks for the presence of at least one , since it even accepts =rm
(maybe that's another bug?).  On the other hand, using =m as constraint
gives an error
bug.c:141:2: error: '' constraint used with no register class

According to http://gcc.gnu.org/onlinedocs/gcc/Multi_002dAlternative.html,
the constraint =rm counts as ONE alternative, since alternatives are
seperated by commas.  This is one alternative, allowing both a register or
memory location.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41294



[Bug c/41263] New: gcc uses all available memory

2009-09-04 Thread jdemeyer at cage dot ugent dot be
When compiling the attached program with the command line 
gcc -v -save-temps -O2 bug.i
gcc uses all available memory.

gcc -v gives me
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc/configure CC=/usr/bin/gcc-4.3.4
--prefix=/home/jdemeyer/local --enable-checking=release
Thread model: posix
gcc version 4.5.0 20090904 (experimental) (GCC)


-- 
   Summary: gcc uses all available memory
   Product: gcc
   Version: 4.5.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jdemeyer at cage dot ugent dot be
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41263



[Bug c/41263] gcc uses all available memory

2009-09-04 Thread jdemeyer at cage dot ugent dot be


--- Comment #1 from jdemeyer at cage dot ugent dot be  2009-09-04 13:21 
---
Created an attachment (id=18493)
 -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=18493action=view)
Testcase


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41263



[Bug inline-asm/37195] different variables get the same overlapping memory address in inline assembly

2008-09-29 Thread jdemeyer at cage dot ugent dot be


--- Comment #5 from jdemeyer at cage dot ugent dot be  2008-09-29 19:22 
---
Created an attachment (id=16428)
 -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=16428action=view)
Unified testcase

This testcase exhibits the problem on i386, x86_64, powerpc and powerpc64 using
preprocessor macros.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37195



[Bug c/37544] New: Conversion double - unsigned long long - unsigned - double gives wrong results

2008-09-16 Thread jdemeyer at cage dot ugent dot be
Consider the following line of the attached test case, where a is double with
value 4294967296.0.

double b = (unsigned int)((unsigned long long int)a % 4294967296ULL);

Then (unsigned long long int)a % 4294967296ULL should be equal to 0ULL, and
therefore b should be 0.0.  However, when compiled with -O1 -march=pentium4, b
gets the wrong value of 4294967296.0 (the same as a).  Note that the error only
occurs with -march=pentium4.

To compile the testcase:
gcc -std=c99 -O1 -march=pentium4 convert-bug.i -o convert-bug

gcc -v:
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc/configure --enable-checking=release
--prefix=/home/jdemeyer/local CC=gcc-4.1.2
Thread model: posix
gcc version 4.4.0 20080916 (experimental) (GCC)


-- 
   Summary: Conversion double - unsigned long long - unsigned -
double gives wrong results
   Product: gcc
   Version: 4.4.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jdemeyer at cage dot ugent dot be
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37544



[Bug c/37544] Conversion double - unsigned long long - unsigned - double gives wrong results

2008-09-16 Thread jdemeyer at cage dot ugent dot be


--- Comment #1 from jdemeyer at cage dot ugent dot be  2008-09-16 16:40 
---
Created an attachment (id=16339)
 -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=16339action=view)
Testcase


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37544



[Bug c/37544] Conversion double - unsigned long long - unsigned - double gives wrong results

2008-09-16 Thread jdemeyer at cage dot ugent dot be


--- Comment #3 from jdemeyer at cage dot ugent dot be  2008-09-16 18:39 
---
In fact, with -mno-sse the problem disappears for me too.
I *do* get the problem with
gcc -std=c99 -O1 -march=i386 -msse2 -mfpmath=387


-- 

jdemeyer at cage dot ugent dot be changed:

   What|Removed |Added

  Component|target  |c


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37544



[Bug inline-asm/37195] different variables get the same memory address in inline assembly

2008-09-03 Thread jdemeyer at cage dot ugent dot be


--- Comment #4 from jdemeyer at cage dot ugent dot be  2008-09-03 07:57 
---
Created an attachment (id=16200)
 -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=16200action=view)
Testcase for powerpc-unknown-linux-gnu

Also fails on powerpc:
$ gcc -O1 test37195-powerpc.i -save-temps -c -o test37195-powerpc.o
test37195-powerpc.s: Assembler messages:
test37195-powerpc.s:119: Error: ASM 2: %1 and %5 are both equal to 16(1)
test37195-powerpc.s:192: Error: ASM 3: %2 and %5 are both equal to 16(1)

$ gcc -v
Using built-in specs.
Target: powerpc-unknown-linux-gnu
Configured with: /var/tmp/portage/sys-devel/gcc-4.2.4/work/gcc-4.2.4/configure
--prefix=/usr --bindir=/usr/powerpc-unknown-linux-gnu/gcc-bin/4.2.4
--includedir=/usr/lib/gcc/powerpc-unknown-linux-gnu/4.2.4/include
--datadir=/usr/share/gcc-data/powerpc-unknown-linux-gnu/4.2.4
--mandir=/usr/share/gcc-data/powerpc-unknown-linux-gnu/4.2.4/man
--infodir=/usr/share/gcc-data/powerpc-unknown-linux-gnu/4.2.4/info
--with-gxx-include-dir=/usr/lib/gcc/powerpc-unknown-linux-gnu/4.2.4/include/g++-v4
--host=powerpc-unknown-linux-gnu --build=powerpc-unknown-linux-gnu
--enable-altivec --enable-nls --without-included-gettext --with-system-zlib
--disable-checking --disable-werror --enable-secureplt --disable-multilib
--enable-libmudflap --disable-libssp --disable-libgcj
--enable-languages=c,c++,treelang,fortran --enable-shared
--enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu
Thread model: posix
gcc version 4.2.4 (Gentoo 4.2.4 p1.0)


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37195



[Bug inline-asm/37195] unrelated variables get the same memory address in inline assembly

2008-09-02 Thread jdemeyer at cage dot ugent dot be


--- Comment #3 from jdemeyer at cage dot ugent dot be  2008-09-02 08:52 
---
Created an attachment (id=16187)
 -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=16187action=view)
Further testcase simplification

The third testcase uses only rm and =rm constraints, which means that it
might not be specific to i386 targets.  I still have to try other targets. 
Note that the bug only occurs if there are sufficiently many registers in the
clobber list (otherwise the compiler just uses registers for everything).


-- 

jdemeyer at cage dot ugent dot be changed:

   What|Removed |Added

  Attachment #16183|0   |1
is obsolete||


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37195



[Bug inline-asm/37195] unrelated variables get the same memory address in inline assembly

2008-09-01 Thread jdemeyer at cage dot ugent dot be


--- Comment #2 from jdemeyer at cage dot ugent dot be  2008-09-01 18:18 
---
Created an attachment (id=16183)
 -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=16183action=view)
Better and simpler test case

The second test case, asmtest2.i exhibits the bug on even more versions of gcc.
 To run the testcase, do
gcc -O1 -save-temps asmtest2.i -o asmtest2

Consider the following piece of inline assembly (the second one of asmtest2.i):
asm(# ASM 2\n
movl %5, %2\n
movl %4, %0\n
movl %0, %1\n
movl %3, %0\n
: =a (c0), =rm (c1), =rm (c2)
: rm (b0), rm (b1), 0 (b2)
: cc, %esi, %edi, %edx
);

gcc 4.3.2 compiles this as
movl %eax, -40(%ebp)
movl -24(%ebp), %eax
movl %eax, -44(%ebp)
movl -40(%ebp), %eax

Note that %2 and %3 are both stored in -40(%ebp).  I think this is a bug.

I have tried this with the following versions of gcc, all of which have the
bug: 3.4.6, 4.0.3, 4.1.2, 4.2.4, 4.3.1, 4.3.2


-- 

jdemeyer at cage dot ugent dot be changed:

   What|Removed |Added

  Attachment #16123|0   |1
is obsolete||


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37195



[Bug inline-asm/37195] unrelated variables get the same memory address in inline assembly

2008-09-01 Thread jdemeyer at cage dot ugent dot be


-- 

jdemeyer at cage dot ugent dot be changed:

   What|Removed |Added

   Severity|normal  |major


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37195



[Bug inline-asm/37195] unrelated variables get the same memory address in inline assembly

2008-09-01 Thread jdemeyer at cage dot ugent dot be


-- 

jdemeyer at cage dot ugent dot be changed:

   What|Removed |Added

 CC||jdemeyer at cage dot ugent
   ||dot be
   Severity|major   |normal
Version|4.3.2   |4.4.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37195



[Bug inline-asm/37195] New: unrelated variables get the same memory address in inline assembly

2008-08-21 Thread jdemeyer at cage dot ugent dot be
In the following inline assembly statement (the second one in the attached
program), the operands %0 and %5 are stored in exactly the same memory address
-44(%ebp), even though they refer to different variables (and all the output
constraints have the earlyclobber modifier).

asm(   shrdl %6, %4, %3\n
   movl %3, %0\n
   movl %5, %2\n
   shrdl %6, %2, %1\n
   shrl %6, %2\n
: =rm (d0), =r (d1), =r (d2)
: 2 (c0), 1 (c1), g (c2), cI (s)
: %eax, %esi, %edi, cc
);

This code is compiled as
shrdl %cl, %edx, %ebx
movl %ebx, -40(%ebp)
movl -40(%ebp), %ebx
shrdl %cl, %ebx, %edx
shrl %cl, %ebx


Command line:
gcc-4.2.4 -O1 -save-temps asmtest.c -c -o asmtest.o

Note: gcc 4.3.1 does not seem to have this problem.


Output of gcc -v:
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: /var/tmp/portage/sys-devel/gcc-4.2.4/work/gcc-4.2.4/configure
--prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/4.2.4
--includedir=/usr/lib/gcc/i686-pc-linux-gnu/4.2.4/include
--datadir=/usr/share/gcc-data/i686-pc-linux-gnu/4.2.4
--mandir=/usr/share/gcc-data/i686-pc-linux-gnu/4.2.4/man
--infodir=/usr/share/gcc-data/i686-pc-linux-gnu/4.2.4/info
--with-gxx-include-dir=/usr/lib/gcc/i686-pc-linux-gnu/4.2.4/include/g++-v4
--host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --disable-altivec
--enable-nls --without-included-gettext --with-system-zlib --disable-checking
--disable-werror --enable-secureplt --disable-multilib --enable-libmudflap
--disable-libssp --disable-libgcj --with-arch=i686
--enable-languages=c,c++,treelang,fortran --enable-shared
--enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu
Thread model: posix
gcc version 4.2.4 (Gentoo 4.2.4)


-- 
   Summary: unrelated variables get the same memory address in
inline assembly
   Product: gcc
   Version: 4.2.4
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: inline-asm
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jdemeyer at cage dot ugent dot be
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37195



[Bug inline-asm/37195] unrelated variables get the same memory address in inline assembly

2008-08-21 Thread jdemeyer at cage dot ugent dot be


--- Comment #1 from jdemeyer at cage dot ugent dot be  2008-08-21 21:16 
---
Created an attachment (id=16123)
 -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=16123action=view)
Source code which shows the problem


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37195