This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/65916] New: Unnecessary floating-point instruction causes runtime exception on PowerPC
- From: "nikolay.pakulin at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 28 Apr 2015 07:36:25 +0000
- Subject: [Bug c/65916] New: Unnecessary floating-point instruction causes runtime exception on PowerPC
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65916
Bug ID: 65916
Summary: Unnecessary floating-point instruction causes runtime
exception on PowerPC
Product: gcc
Version: 4.9.1
Status: UNCONFIRMED
Severity: critical
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: nikolay.pakulin at gmail dot com
Target Milestone: ---
Created attachment 35412
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35412&action=edit
Test case to reproduce the issue
Writing 64-bit integers to memory on 32-bit PPC involves floating point
register FP0. When floating-point support is disabled (bit FP is cleared in
MSR register) the generated code leads to exception "FP unavailable interrupt".
The test case compiled by GCC cross compiler running on x86_64 Linux.
powerpc-elf-gcc -S -m32 -mcpu=e500mc uint64.c
-- uint64.c --
typedef unsigned long long u64;
u64 globvar;
void f(u64 arg) {
globvar = arg;
}
-- /uint64.c --
-- Generated ASM --
f:
stwu 1,-32(1)
stw 31,28(1)
mr 31,1
stw 3,8(31) # Copies 'arg' to the temporary on the stack
stw 4,12(31) #
lis 9,globvar@ha
la 9,globvar@l(9)
lfd 0,8(31) # Loads the temporary to FP0 -- exception!
stfd 0,0(9) # Store FP0 to memory
addi 11,31,32
lwz 31,-4(11)
mr 1,11
blr
-- End of Generated ASM --
== GCC specs ==
Using built-in specs.
COLLECT_GCC=powerpc-elf-gcc
COLLECT_LTO_WRAPPER=/opt/crosstools/powerpc-elf-4.9.1-Linux-x86_64/bin/../libexec/gcc/powerpc-elf/4.9.1/lto-wrapper
Target: powerpc-elf
Configured with: ../gcc-4.9.1/configure --target=powerpc-elf
--prefix=/home/geist/svn/toolchains/powerpc-elf-4.9.1-Linux-x86_64
--enable-languages=c,c++ --disable-werror
Thread model: single
gcc version 4.9.1 (GCC)
== End of GCC specs ==
The workaround is to compile with optimization turned on. With -O switch GCC
produces ASM without FP0:
powerpc-elf-gcc -S -m32 -mcpu=e500mc -O uint64.c
-- Generated optimized ASM --
f:
lis 9,globvar@ha
la 9,globvar@l(9)
stw 3,0(9) # direct write to the destination
stw 4,4(9) #
blr
-- End of generated optimized ASM --