diff mbox

PR 42751, Fix conversion of unsigned to float on powerpc -m32 -msoft-float -mcpu=power7

Message ID 20110111002842.GA22074@hungry-tiger.westford.ibm.com
State New
Headers show

Commit Message

Michael Meissner Jan. 11, 2011, 12:28 a.m. UTC
When I put in the floating point conversion changes, I forgot to check whether
hardware floating point was available if the user did -mcpu=power7.  This shows
up if you try to build a compiler configured using --with-cpu=power7.  The
failure is the compiler generates this insn, and then gets a reload failure
because there are no floating point registers available with -msoft-float.

There are some other problems in building a compiler with the --with-cpu=power7
option, but this fixes the immediate problem.

I did bootstrap builds with/without the patch, and there were no regressions in
the test suite.  Is this patch ok to apply?

[gcc]
2011-01-10  Michael Meissner  <meissner@linux.vnet.ibm.com>

	PR target/42751
	* config/rs6000/rs6000.md (floatunsdidf2): Add check for hardware
	floating point.
	(floatunsdidf2_fcfidu): Ditto.

[gcc/testsuite]
2011-01-10  Michael Meissner  <meissner@linux.vnet.ibm.com>

	PR target/42751
	* gcc.target/powerpc/pr47251.c: New file, test PR 42751 fix.

Comments

David Edelsohn Jan. 13, 2011, 1:40 p.m. UTC | #1
On Mon, Jan 10, 2011 at 7:28 PM, Michael Meissner
<meissner@linux.vnet.ibm.com> wrote:
> When I put in the floating point conversion changes, I forgot to check whether
> hardware floating point was available if the user did -mcpu=power7.  This shows
> up if you try to build a compiler configured using --with-cpu=power7.  The
> failure is the compiler generates this insn, and then gets a reload failure
> because there are no floating point registers available with -msoft-float.
>
> There are some other problems in building a compiler with the --with-cpu=power7
> option, but this fixes the immediate problem.
>
> I did bootstrap builds with/without the patch, and there were no regressions in
> the test suite.  Is this patch ok to apply?
>
> [gcc]
> 2011-01-10  Michael Meissner  <meissner@linux.vnet.ibm.com>
>
>        PR target/42751
>        * config/rs6000/rs6000.md (floatunsdidf2): Add check for hardware
>        floating point.
>        (floatunsdidf2_fcfidu): Ditto.
>
> [gcc/testsuite]
> 2011-01-10  Michael Meissner  <meissner@linux.vnet.ibm.com>
>
>        PR target/42751
>        * gcc.target/powerpc/pr47251.c: New file, test PR 42751 fix.

Okay.

Thanks, David
diff mbox

Patch

Index: gcc/config/rs6000/rs6000.md
===================================================================
--- gcc/config/rs6000/rs6000.md	(revision 168634)
+++ gcc/config/rs6000/rs6000.md	(working copy)
@@ -7167,13 +7167,13 @@  (define_expand "floatunsdidf2"
   [(set (match_operand:DF 0 "gpc_reg_operand" "")
 	(unsigned_float:DF
 	 (match_operand:DI 1 "gpc_reg_operand" "")))]
-  "TARGET_FCFIDU || VECTOR_UNIT_VSX_P (DFmode)"
+  "TARGET_HARD_FLOAT && (TARGET_FCFIDU || VECTOR_UNIT_VSX_P (DFmode))"
   "")
 
 (define_insn "*floatunsdidf2_fcfidu"
   [(set (match_operand:DF 0 "gpc_reg_operand" "=d")
 	(unsigned_float:DF (match_operand:DI 1 "gpc_reg_operand" "d")))]
-  "TARGET_FCFIDU && !VECTOR_UNIT_VSX_P (DFmode)"
+  "TARGET_HARD_FLOAT && TARGET_FCFIDU && !VECTOR_UNIT_VSX_P (DFmode)"
   "fcfidu %0,%1"
   [(set_attr "type" "fp")
    (set_attr "length" "4")])
@@ -7182,7 +7182,7 @@  (define_insn_and_split "*floatunsdidf2_m
   [(set (match_operand:DF 0 "gpc_reg_operand" "=d")
 	(unsigned_float:DF (match_operand:DI 1 "memory_operand" "m")))
    (clobber (match_scratch:DI 2 "=d"))]
-  "TARGET_FCFIDU || VECTOR_UNIT_VSX_P (DFmode)"
+  "TARGET_HARD_FLOAT && (TARGET_FCFIDU || VECTOR_UNIT_VSX_P (DFmode))"
   "#"
   "&& reload_completed"
   [(set (match_dup 2) (match_dup 1))
bash: svi: command not found
Index: gcc/testsuite/gcc.target/powerpc/pr47251.c
===================================================================
--- gcc/testsuite/gcc.target/powerpc/pr47251.c	(revision 0)
+++ gcc/testsuite/gcc.target/powerpc/pr47251.c	(revision 0)
@@ -0,0 +1,15 @@ 
+/* { dg-do compile { target { powerpc*-*-* && ip32 } } } */
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
+/* { dg-require-effective-target powerpc_vsx_ok } */
+/* { dg-options "-O2 -msoft-float -mcpu=power7" } */
+
+/* PR 47151: libgcc fails to build when using --with-cpu=power7 due to a missed
+   TARGET_HARD_FLOAT test.  */
+unsigned int
+__fixunssfdi (float a)
+{
+  const float dfa = a;
+  const unsigned int hi = dfa / 0x1p32f;
+  const unsigned int lo = dfa - (float) hi * 0x1p32f;
+  return ((unsigned int) hi << (4 * 8)) | lo;
+}