For following program int func(float f) { double d = (double)f; return (int)d; } compile it with following command: $ arm-none-eabi-gcc -O2 -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -S test.c -o test.S the generated assembly code is: ----------------------------------------------- fun: @ args = 0, pretend = 0, frame = 0 @ frame_needed = 0, uses_anonymous_args = 0 push {r3, lr} fmrs r0, s0 bl __aeabi_f2d fmdrr d0, r0, r1 bl __aeabi_d2iz pop {r3, pc} .size fun, .-fun The argument of __aeabi_d2iz is passed in fp register, While ARM RTABI document says that such functions should use the soft-float ABI, even when -mfloat-abi=hard is specified. The problem at least exists on trunk and 4.6 branch. I am working a patch and will send it for review later.
Confirmed
This is only applicable to the 4.6 branch and trunk since support for the Cortex M4 wasn't added till 4.6. cheers Ramana
Author: jye2 Date: Mon Jan 30 16:59:14 2012 New Revision: 183733 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=183733 Log: 2012-01-30 Bin Cheng <bin.cheng@arm.com> PR target/51835 * config/arm/arm.c (arm_libcall_uses_aapcs_base): Use correct ABI for __aeabi_d2iz/__aeabi_d2uiz with hard-float. testcases: PR target/51835 * gcc.target/arm/pr51835.c: New testcase. Added: trunk/gcc/testsuite/gcc.target/arm/pr51835.c Modified: trunk/gcc/ChangeLog trunk/gcc/config/arm/arm.c trunk/gcc/testsuite/ChangeLog
Author: jye2 Date: Mon Jan 30 17:22:04 2012 New Revision: 183734 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=183734 Log: 2012-01-30 Bin Cheng <bin.cheng@arm.com> PR target/51835 * config/arm/arm.c (arm_libcall_uses_aapcs_base): Use correct ABI for __aeabi_d2iz/__aeabi_d2uiz with hard-float. testcases: PR target/51835 * gcc.target/arm/pr51835.c: New testcase. Added: branches/gcc-4_6-branch/gcc/testsuite/gcc.target/arm/pr51835.c Modified: branches/gcc-4_6-branch/gcc/ChangeLog branches/gcc-4_6-branch/gcc/config/arm/arm.c branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
(In reply to comment #2) > This is only applicable to the 4.6 branch and trunk since support for the > Cortex M4 wasn't added till 4.6. > > cheers > Ramana Maybe the Cortex M4 wasn't added until 4.6, but the other options are permitted by 4.5 and I can easily get 4.5 to produce wrong-looking code. With -O2 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -march=armv7-a -marm I see the following code generation difference between 4.5 and 4.6: @@ -22,8 +22,9 @@ @ frame_needed = 0, uses_anonymous_args = 0 stmfd sp!, {r3, lr} bl __aeabi_f2d + fmrrd r0, r1, d0 bl __aeabi_d2iz ldmfd sp!, {r3, pc} .size func, .-func - .ident "GCC: (GNU) 4.5.4 20120126 (prerelease)" + .ident "GCC: (GNU) 4.6.3 20120203 (prerelease)" .section .note.GNU-stack,"",%progbits Backporting r183734 from 4.6 to 4.5 makes 4.5 generate the same code as 4.6, i.e., with the fmrrd between the two calls.
(In reply to comment #5) > (In reply to comment #2) > > This is only applicable to the 4.6 branch and trunk since support for the > > Cortex M4 wasn't added till 4.6. > > > > cheers > > Ramana > > Maybe the Cortex M4 wasn't added until 4.6, but the other options are permitted > by 4.5 and I can easily get 4.5 to produce wrong-looking code. With -O2 > -mfloat-abi=hard -mfpu=fpv4-sp-d16 -march=armv7-a -marm I see the following > code generation difference between 4.5 and 4.6: > > @@ -22,8 +22,9 @@ > @ frame_needed = 0, uses_anonymous_args = 0 > stmfd sp!, {r3, lr} > bl __aeabi_f2d > + fmrrd r0, r1, d0 > bl __aeabi_d2iz > ldmfd sp!, {r3, pc} > .size func, .-func > - .ident "GCC: (GNU) 4.5.4 20120126 (prerelease)" > + .ident "GCC: (GNU) 4.6.3 20120203 (prerelease)" > .section .note.GNU-stack,"",%progbits > > Backporting r183734 from 4.6 to 4.5 makes 4.5 generate the same code as 4.6, > i.e., with the fmrrd between the two calls. beside this patch, Julian Brown's patch r174803 is necessary too. For now, 1, arguments for both __aeabi_f2d and __aeabi_d2iz are wrong in 4.5; 2, arguments for __aeabi_f2d is wrong in 4.6 To solve this, have to: 1, backport r183734 and r174803 to 4.5; 2, backport r174803 to 4.6;
Author: amker Date: Fri Feb 10 03:14:40 2012 New Revision: 184082 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=184082 Log: Backport from mainline. 2012-01-30 Bin Cheng <bin.cheng@arm.com> PR target/51835 * config/arm/arm.c (arm_libcall_uses_aapcs_base): Use correct ABI for __aeabi_d2iz/__aeabi_d2uiz with hard-float. Backport from mainline. 2012-01-30 Bin Cheng <bin.cheng@arm.com> PR target/51835 * gcc.target/arm/pr51835.c: New testcase. Added: branches/ARM/embedded-4_6-branch/gcc/testsuite/gcc.target/arm/pr51835.c Modified: branches/ARM/embedded-4_6-branch/gcc/ChangeLog.arm branches/ARM/embedded-4_6-branch/gcc/config/arm/arm.c branches/ARM/embedded-4_6-branch/gcc/testsuite/ChangeLog.arm
Author: amker Date: Tue Feb 14 07:42:41 2012 New Revision: 184197 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=184197 Log: Backport from mainline. 2012-01-30 Bin Cheng <bin.cheng@arm.com> PR target/51835 * config/arm/arm.c (arm_libcall_uses_aapcs_base): Use correct ABI for __aeabi_d2iz/__aeabi_d2uiz with hard-float. 2011-06-08 Julian Brown <julian@codesourcery.com> * config/arm/arm.c (arm_libcall_uses_aapcs_base): Use correct ABI for double-precision helper functions in hard-float mode if only single-precision arithmetic is supported in hardware. Added: branches/gcc-4_5-branch/gcc/testsuite/gcc.target/arm/pr51835.c Modified: branches/gcc-4_5-branch/gcc/ChangeLog branches/gcc-4_5-branch/gcc/config/arm/arm.c branches/gcc-4_5-branch/gcc/testsuite/ChangeLog
Fixed I think now on all release branches where affected and trunk.