This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] m68k: Fix PR target/28911
- From: Kazu Hirata <kazu at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: law at redhat dot com, schwab at suse dot de
- Date: Sun, 24 Sep 2006 09:25:33 -0700
- Subject: [patch] m68k: Fix PR target/28911
Hi,
Attached is a patch to fix target/28911.
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 and x86_64-pc-linux-gnu. 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 (-2147483648), 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 (-2147483648), 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 (-2147483648), 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);
+}