Patchwork Using gen_int_mode instead of GEN_INT minot testsuite fallout on MIPS

login
register
mail settings
Submitter Graham Stott
Date Sept. 12, 2013, 11:48 a.m.
Message ID <1378986519.68553.YahooMailNeo@web87401.mail.ir2.yahoo.com>
Download mbox | patch
Permalink /patch/274531/
State New
Headers show

Comments

Graham Stott - Sept. 12, 2013, 11:48 a.m.
Hi Richard,

After applying just the cse.c part of the patch the two testcases no longer ICE and pass
with regressions in C or C++ testsuites.


Not sure if we really need the other part of the patch to gen_int_mode ().

Graham



----- Original Message -----
From: Richard Sandiford <rdsandiford@googlemail.com>
To: Graham Stott <graham.stott@btinternet.com>
Cc: James Greenhalgh <james.greenhalgh@arm.com>; "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Sent: Wednesday, 11 September 2013, 19:39
Subject: Re: Using gen_int_mode instead of GEN_INT minot testsuite fallout on MIPS

Graham Stott <graham.stott@btinternet.com> writes:
> Hi Richard,
>
> There is some minor testsuite fallout with these patches on MIPS a
> couple of tests (see below)ICE ingen_int_mode () in both these ICE the
> mode is CCmode.

Hmm, interesting.  I suppose gen_int_mode should handle CC modes,
since there's no other constant rtx that can be used instead.  OTOH,
like you say, it doesn't really make sense to apply try_const_anchor
to CCmode.

How does the following patch look?

Thanks,
Richard


gcc/
    * emit-rtl.c (gen_int_mode): Handle CC modes.
    * cse.c (try_const_anchors): ...but punt on them here.

Patch

Index: gcc/emit-rtl.c
===================================================================
--- gcc/emit-rtl.c    2013-09-08 11:52:15.000000000 +0100
+++ gcc/emit-rtl.c    2013-09-11 19:32:35.702377902 +0100
@@ -417,6 +417,11 @@  gen_rtx_CONST_INT (enum machine_mode mod
rtx
gen_int_mode (HOST_WIDE_INT c, enum machine_mode mode)
{
+  /* CONST_INT is used for CC modes too.  We can't make any assumptions
+     about the precision or bitsize in that case, so just pass the value
+     through unchanged.  */
+  if (GET_MODE_CLASS (mode) == MODE_CC)
+    return GEN_INT (c);
   return GEN_INT (trunc_int_for_mode (c, mode));
}

Index: gcc/cse.c
===================================================================
--- gcc/cse.c    2013-09-08 11:52:15.000000000 +0100
+++ gcc/cse.c    2013-09-11 19:38:17.664399826 +0100
@@ -1354,6 +1354,11 @@  try_const_anchors (rtx src_const, enum m
   rtx lower_exp = NULL_RTX, upper_exp = NULL_RTX;
   unsigned lower_old, upper_old;

+  /* CONST_INT is used for CC modes, but we should leave those alone.  */
+  if (GET_MODE_CLASS (mode) == MODE_CC)
+    return NULL_RTX;
+
+  gcc_assert (SCALAR_INT_MODE_P (mode));
   if (!compute_const_anchors (src_const, &lower_base, &lower_offs,
                  &upper_base, &upper_offs))
     return NULL_RTX;