https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103424

            Bug ID: 103424
           Summary: Ignoring -mfpu=sp_full/-mfpu=-sp_lite/-msingle-float
           Product: gcc
           Version: 8.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libgcc
          Assignee: unassigned at gcc dot gnu.org
          Reporter: andrea.bellandi at desy dot de
  Target Milestone: ---

When passing "-mfpu=sp_full/-mfpu=-sp_lite/-msingle-float" to CFLAGS with
--target=powerpc-xilinx-eabi/--target=powerpc-xilinx-eabisim, libgcc should be
compiled with hard- single precision fpu code and soft- double precision (see
https://gcc.gnu.org/onlinedocs/gcc-8.5.0/gcc/RS_002f6000-and-PowerPC-Options.html#RS_002f6000-and-PowerPC-Options).

However these flags are ignored (no apparent reference to them in libgcc).
Therefore the library attempt a compilation with both single- and double- soft
floating point replacement.

How to reproduce:

Compilation failure of the whole 'gcc product' with the following parameters

CFLAGS_FOR_TARGET="-g -O2 -mxilinx-fpu -msingle-float" ../gcc/configure
--target=powerpc-xilinx-eabi --prefix="$PREFIX" --disable-nls --with-tune=440
--enable-languages=c,c++ --without-headers

make all-gcc 
make all-target-libgcc

Error: 

/home/bellandi/Projects/build-gcc/./gcc/xgcc
-B/home/bellandi/Projects/build-gcc/./gcc/
-B/home/bellandi/.local/cross/powerpc-xilinx-eabi/bin/
-B/home/bellandi/.local/cross/powerpc-xilinx-eabi/lib/ -isystem
/home/bellandi/.local/cross/powerpc-xilinx-eabi/include -isystem
/home/bellandi/.local/cross/powerpc-xilinx-eabi/sys-include    -g -O2
-mfpu=sp_lite -mrelocatable-lib -mno-eabi -mstrict-align -O2  -g -O2 -DIN_GCC 
-DCROSS_DIRECTORY_STRUCTURE  -W -Wall -Wno-narrowing -Wwrite-strings
-Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition 
-isystem ./include   -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector
-Dinhibit_libc  -I. -I. -I../../.././gcc -I../../../../gcc/libgcc
-I../../../../gcc/libgcc/. -I../../../../gcc/libgcc/../gcc
-I../../../../gcc/libgcc/../include    -o _mulsc3.o -MT _mulsc3.o -MD -MP -MF
_mulsc3.dep -DL_mulsc3 -c ../../../../gcc/libgcc/libgcc2.c -fvisibility=hidden
-DHIDE_EXPORTS
during RTL pass: reload                                                         
../../../../gcc/libgcc/libgcc2.c: In function '__mulsc3':                       
../../../../gcc/libgcc/libgcc2.c:2036:1: internal compiler error: Max. number
of generated reload insns per insn is achieved (90)

 }                                                                              
 ^                                                                              
0x8d1519 lra_constraints(bool)                                                  
  ../../gcc/gcc/lra-constraints.c:4836                                          
0x8bf2e4 lra(_IO_FILE*)                                                         
  ../../gcc/gcc/lra.c:2422                                                      
0x87bd49 do_reload                                                              
  ../../gcc/gcc/ira.c:5472                                                      
0x87bd49 execute                                                                
  ../../gcc/gcc/ira.c:5656                                                      
Please submit a full bug report,                                                
with preprocessed source if appropriate.                                        
Please include the complete backtrace with any bug report.                      
See <https://gcc.gnu.org/bugs/> for instructions.                               
make[3]: *** [Makefile:494: _mulsc3.o] Error 1                                  
make[3]: Leaving directory
'/home/bellandi/Projects/build-gcc/powerpc-xilinx-eabi/single/libgcc'
make[2]: *** [Makefile:1201: multi-do] Error 1                                  
make[2]: Leaving directory
'/home/bellandi/Projects/build-gcc/powerpc-xilinx-eabi/libgcc'
make[1]: *** [Makefile:125: all-multi] Error 2                                  
make[1]: Leaving directory
'/home/bellandi/Projects/build-gcc/powerpc-xilinx-eabi/libgcc'
make: *** [Makefile:12382: all-target-libgcc] Error 2 


This probably happens due to the libgcc attempt to generate single precision
code for __mulsc3

Note that the flags should be implemented at least for powerpc-xilinx-eabi. 
See 
https://china.xilinx.com/support/documentation/ip_documentation/apu_fpu.pdf
page 8 
https://www.xilinx.com/support/documentation/ip_documentation/apu_fpu_virtex5.pdf
page 8


Possible fix: 

Perform a configuration simular to the powerpc*-*-linux* for the 'e500v1'
option:
https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libgcc/config.host;h=677173eee432efe784dfe6535b931f63df54cc7c;hb=eafe83f2f20ef0c1e7703c361ba314b44574523c#l1083

Result in the inclusion of t-e500v1-fp
https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libgcc/config/rs6000/t-e500v1-fp;h=ff88acaa8e7af0fadcc4f47f090efd7767839b13;hb=eafe83f2f20ef0c1e7703c361ba314b44574523c

(Not sure if the xilinx fpu support hard unordsf2..)

Note:

For 'lite' versions of the fpu (-mfpu=dp_lite and -mfpu=sp_lite), the fsqrt/s
and div/s instructions have to be  also implemented in the 'soft' version
(maybe using the hardfp_exclusions and softp_extras variables?)

Reply via email to