public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug inline-asm/36923]  New: Crashes with FPU inline-assembly
@ 2008-07-24 20:51 tobias dot doerffel at gmail dot com
  2008-08-03  9:17 ` [Bug target/36923] " ubizjak at gmail dot com
  0 siblings, 1 reply; 2+ messages in thread
From: tobias dot doerffel at gmail dot com @ 2008-07-24 20:51 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 4347 bytes --]

Trying to compile the following (already pre-processed) code causes ICE:

# 1 "gcc-ice.cpp"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "gcc-ice.cpp"
static float fraction( float _x )
{
 int tmp;

 asm ( "fld  %0\n"
  "fld  %%st(0)\n"
  "fisttp %1\n"
  "fild %1\n"
  "fxch\n"
  "fsub %%st(1),%%st(0)\n"
 : "=&t"( _x ), "=m"( tmp )
 : "f"( _x )
 : );
 return( _x );
}

int main( void )
{
 float x = fraction( 2.34634 );
}


Command-line:

g++ -O2 gcc-ice.cpp -save-temps 


Output:

Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.3.1-7ubuntu1'
--with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.3
--program-suffix=-4.3 --enable-clocale=gnu --enable-libstdcxx-debug
--enable-objc-gc --enable-mpfr --enable-targets=all --enable-checking=release
--build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.3.1 (Ubuntu 4.3.1-7ubuntu1)
COLLECT_GCC_OPTIONS='-v' '-O2' '-save-temps' '-msse3' '-mtune=generic'
 /usr/lib/gcc/i486-linux-gnu/4.3.1/cc1plus -E -quiet -v -D_GNU_SOURCE
gcc-ice.cpp -D_FORTIFY_SOURCE=2 -msse3 -mtune=generic -O2 -fpch-preprocess -o
gcc-ice.ii
ignoring nonexistent directory "/usr/local/include/i486-linux-gnu"
ignoring nonexistent directory
"/usr/lib/gcc/i486-linux-gnu/4.3.1/../../../../i486-linux-gnu/include"
ignoring nonexistent directory "/usr/include/i486-linux-gnu"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/4.3
 /usr/include/c++/4.3/i486-linux-gnu
 /usr/include/c++/4.3/backward
 /usr/local/include
 /usr/lib/gcc/i486-linux-gnu/4.3.1/include
 /usr/lib/gcc/i486-linux-gnu/4.3.1/include-fixed
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-O2' '-save-temps' '-msse3' '-mtune=generic'
 /usr/lib/gcc/i486-linux-gnu/4.3.1/cc1plus -fpreprocessed gcc-ice.ii -quiet
-dumpbase gcc-ice.cpp -msse3 -mtune=generic -auxbase gcc-ice -O2 -version
-fstack-protector -o gcc-ice.s
GNU C++ (Ubuntu 4.3.1-7ubuntu1) version 4.3.1 (i486-linux-gnu)
        compiled by GNU C version 4.3.1, GMP version 4.2.2, MPFR version 2.3.1.
GGC heuristics: --param ggc-min-expand=98 --param ggc-min-heapsize=129034
Compiler executable checksum: 8789ae6462ba1c03375bc751bf9f310c
gcc-ice.cpp: In function ‘int main()’:
gcc-ice.cpp:20: error: unrecognizable insn:
(insn:TI 7 6 41 gcc-ice.cpp:13 (parallel [
            (set (reg:SF 8 st)
                (asm_operands:SF ("fld  %0
fld     %%st(0)
fisttp %1
fild    %1
fxch
fsub    %%st(1),%%st(0)
") ("=&t") 0 [
                        (reg:SF 8 st)
                    ]
                     [
                        (asm_input:SF ("f") 0)
                    ] 2058))
            (set (mem/c/i:SI (plus:SI (reg/f:SI 6 bp)
                        (const_int -8 [0xfffffffffffffff8])) [2 tmp+0 S4 A32])
                (asm_operands:SI ("fld  %0
fld     %%st(0)
fisttp %1
fild    %1
fxch
fsub    %%st(1),%%st(0)
") ("=m") 1 [
                        (reg:SF 8 st)
                    ]
                     [
                        (asm_input:SF ("f") 0)
                    ] 2058))
            (clobber (reg:QI 18 fpsr))
            (clobber (reg:QI 17 flags))
        ]) -1 (expr_list:REG_DEAD (reg:SF 8 st)
        (expr_list:REG_UNUSED (reg:QI 18 fpsr)
            (expr_list:REG_UNUSED (reg:QI 17 flags)
                (expr_list:REG_UNUSED (reg:SF 8 st)
                    (nil))))))
gcc-ice.cpp:20: internal compiler error: in extract_constrain_insn_cached, at
recog.c:1907
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.3/README.Bugs> for instructions.


-- 
           Summary: Crashes with FPU inline-assembly
           Product: gcc
           Version: 4.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: inline-asm
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tobias dot doerffel at gmail dot com
 GCC build triplet: i486-linux-gnu
  GCC host triplet: i486-linux-gnu
GCC target triplet: i486-linux-gnu


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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug target/36923] Crashes with FPU inline-assembly
  2008-07-24 20:51 [Bug inline-asm/36923] New: Crashes with FPU inline-assembly tobias dot doerffel at gmail dot com
@ 2008-08-03  9:17 ` ubizjak at gmail dot com
  0 siblings, 0 replies; 2+ messages in thread
From: ubizjak at gmail dot com @ 2008-08-03  9:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from ubizjak at gmail dot com  2008-08-03 09:16 -------
Stack asm constraints have some annoying properties. Please note, that in your
testcase, value in %st1 isn't popped from the stack. Also, reverse subtract can
be used to avoid fxch. I propose to rewrite your function as:

static float fraction( float _x )
{
 int tmp;

 asm ( "fld %%st\n\t"
       "fisttp %1\n\t"
       "fild %1\n\t"
       "fsubrp %%st, %%st(1)"
       : "+t"( _x ), "=m"( tmp )
       :
       : "st(1)" );

 return( _x );
}


-- 

ubizjak at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-08-03  9:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-24 20:51 [Bug inline-asm/36923] New: Crashes with FPU inline-assembly tobias dot doerffel at gmail dot com
2008-08-03  9:17 ` [Bug target/36923] " ubizjak at gmail dot com

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).