[patch] m68k: Fix PR target/28911 (Take 2)

Kazu Hirata kazu@codesourcery.com
Sun Sep 24 17:58:00 GMT 2006


Hi,

Attached is a revised patch to fix PR target/28911.

This version of the patch incorporates a suggestion from Andrew Pinski
to say -2147483647 - 1 instead of -2147483648 to avoid problems on
32-bit machines.

m68k.md calls GEN_INT (0x80000000) and uses that in SImode operations,
which is invalid.

Compiling the attached testcase trips the following gcc_assert in
combine.c:do_SUBST.

      gcc_assert (INTVAL (newval)
		  == trunc_int_for_mode (INTVAL (newval), GET_MODE (oldval)));

The patch fixes the problem by using -2147483648 instead of
0x80000000.

Tested on m68k-elf.  OK to apply?

Kazu Hirata

2006-09-24  Kazu Hirata  <kazu@codesourcery.com>

	PR target/28911
	* config/m68k/m68k.md (negsf2, negdf2, negxf2): Use
	-2147483648 instead of 0x80000000.

2006-09-24  Kazu Hirata  <kazu@codesourcery.com>

	PR target/28911
	* gcc.dg/pr28911.c.

Index: config/m68k/m68k.md
===================================================================
--- config/m68k/m68k.md	(revision 117177)
+++ config/m68k/m68k.md	(working copy)
@@ -3721,7 +3721,7 @@ (define_expand "negsf2"
       target = operand_subword_force (operands[0], 0, SFmode);
       result = expand_binop (SImode, xor_optab,
 			     operand_subword_force (operands[1], 0, SFmode),
-			     GEN_INT (0x80000000), target, 0, OPTAB_WIDEN);
+			     GEN_INT (-2147483647 - 1), target, 0, OPTAB_WIDEN);
       gcc_assert (result);
 
       if (result != target)
@@ -3748,7 +3748,7 @@ (define_expand "negdf2"
       target = operand_subword (operands[0], 0, 1, DFmode);
       result = expand_binop (SImode, xor_optab,
 			     operand_subword_force (operands[1], 0, DFmode),
-			     GEN_INT (0x80000000), target, 0, OPTAB_WIDEN);
+			     GEN_INT (-2147483647 - 1), target, 0, OPTAB_WIDEN);
       gcc_assert (result);
 
       if (result != target)
@@ -3780,7 +3780,7 @@ (define_expand "negxf2"
       target = operand_subword (operands[0], 0, 1, XFmode);
       result = expand_binop (SImode, xor_optab,
 			     operand_subword_force (operands[1], 0, XFmode),
-			     GEN_INT (0x80000000), target, 0, OPTAB_WIDEN);
+			     GEN_INT (-2147483647 - 1), target, 0, OPTAB_WIDEN);
       gcc_assert (result);
 
       if (result != target)
Index: testsuite/gcc.dg/pr28911.c
===================================================================
--- testsuite/gcc.dg/pr28911.c	(revision 0)
+++ testsuite/gcc.dg/pr28911.c	(revision 0)
@@ -0,0 +1,13 @@
+/* PR target/28911
+   The following used to cause crash on m68k-elf because 0x80000000
+   was used as an SImode constant.  */
+
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+/* { dg-options "-O2 -m68000" { target m68k-*-* } } */
+
+_Complex float
+foo (float a)
+{
+  return __builtin_copysign (a != a, a);
+}



More information about the Gcc-patches mailing list