[google/4.6]Backport r184061 from upstream 4.6 (issue5712053)

Jing Yu jingyu@google.com
Thu Mar 1 21:30:00 GMT 2012


The patch will be auto-merged into google/gcc-4_6 in near future.
I will cherry-pick it into google/gcc-4_6_2-mobile.

On Thu, Mar 1, 2012 at 10:50 AM, Jing Yu <jingyu@google.com> wrote:
> Backport r184061 from gcc-4_6 branch to fix an invalid
> constant simplification (PR52060).
>
> bootstrap and crosstool tests pass.
>
> OK for google/gcc-4_6 and google/gcc-4_6_2-mobile?
>
>
> 2012-03-01  Jing Yu  <jingyu@google.com>
>        Backport r184061 from gcc-4_6-branch to fix PR52060.
>
>        2012-02-07  Jakub Jelinek  <jakub@redhat.com>
>        PR rtl-optimization/52060
>        * gcc.dg/torture/pr52060.c: New test.
>
> 2012-03-01   Jing Yu  <jingyu@google.com>
>        Backport r184061 from gcc-4_6-branch to fix PR52060.
>
>        2012-02-07  Jakub Jelinek  <jakub@redhat.com>
>        PR rtl-optimization/52060
>        * combine.c (try_combine): Add i0src_copy and i0src_copy2 variables,
>        copy i1src to i1src_copy whenever added_sets_2 && i1_feeds_i2_n
>        already before i1dest -> i1src substitution in newpat, copy i0src
>        to i0src_copy and/or i0src_copy2 when needed.
>
>
> Index: testsuite/ChangeLog.google-4_6
> ===================================================================
> --- testsuite/ChangeLog.google-4_6      (revision 184667)
> +++ testsuite/ChangeLog.google-4_6      (working copy)
> @@ -1,3 +1,10 @@
> +2012-03-01  Jing Yu  <jingyu@google.com>
> +       Backport r184061 from gcc-4_6-branch to fix PR52060.
> +
> +       2012-02-07  Jakub Jelinek  <jakub@redhat.com>
> +       PR rtl-optimization/52060
> +       * gcc.dg/torture/pr52060.c: New test.
> +
>  2012-02-19  Jeffrey Yasskin <jyasskin@google.com>
>         Backport r183223 from gcc-4_6-branch to fix a segfault in C++11
>        mode.
> Index: testsuite/gcc.dg/torture/pr52060.c
> ===================================================================
> --- testsuite/gcc.dg/torture/pr52060.c  (revision 0)
> +++ testsuite/gcc.dg/torture/pr52060.c  (revision 0)
> @@ -0,0 +1,57 @@
> +/* PR rtl-optimization/52060 */
> +/* { dg-do run { target int32plus } } */
> +
> +extern void abort (void);
> +union U { float f; unsigned int i; };
> +
> +static inline __attribute__((always_inline)) unsigned int
> +foo (float x)
> +{
> +  union U u;
> +  unsigned int a, b, c;
> +  int d;
> +  int e;
> +  u.f = x;
> +  d = ((unsigned) u.i >> 23) & 0xFF;
> +  c = d < 126 ? 0 : ~0;
> +  e = 127 + 30 - d;
> +  a = (u.i << 8) | 0x80000000U;
> +  b = a & ((1 << e) - 1);
> +  a = a >> e;
> +  c &= (b | (a & 2)) ? ~0 : ~1;
> +  a = ((a + 1U) >> 1) & c;
> +  return a;
> +}
> +
> +__attribute__((noinline)) unsigned int
> +bar (float x)
> +{
> +  unsigned int a, b, c;
> +  static const unsigned int d[128] =
> +  {
> +    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
> +    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
> +    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
> +    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
> +    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
> +    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
> +    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
> +    3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 6, 7
> +  };
> +  a = foo (1048575.0f * x);
> +  c = d[a >> 13];
> +  b = (c << 13) | ((a >> (7 - c)) & 0x1fff);
> +  return b;
> +}
> +
> +int
> +main ()
> +{
> +  union U u;
> +  u.f = 1048575.0f;
> +  if (sizeof (u.i) == sizeof (u.f)
> +      && u.i == 0x497ffff0U
> +      && bar (1.0f) != 65535)
> +    abort ();
> +  return 0;
> +}
> Index: ChangeLog.google-4_6
> ===================================================================
> --- ChangeLog.google-4_6        (revision 184667)
> +++ ChangeLog.google-4_6        (working copy)
> @@ -1,3 +1,13 @@
> +2012-03-01   Jing Yu  <jingyu@google.com>
> +       Backport r184061 from gcc-4_6-branch to fix PR52060.
> +
> +       2012-02-07  Jakub Jelinek  <jakub@redhat.com>
> +       PR rtl-optimization/52060
> +       * combine.c (try_combine): Add i0src_copy and i0src_copy2 variables,
> +       copy i1src to i1src_copy whenever added_sets_2 && i1_feeds_i2_n
> +       already before i1dest -> i1src substitution in newpat, copy i0src
> +       to i0src_copy and/or i0src_copy2 when needed.
> +
>  2012-02-21   Jing Yu  <jingyu@google.com>
>
>        Google Ref 47894
> Index: combine.c
> ===================================================================
> --- combine.c   (revision 184667)
> +++ combine.c   (working copy)
> @@ -2551,8 +2551,8 @@
>   rtx i3dest_killed = 0;
>   /* SET_DEST and SET_SRC of I2, I1 and I0.  */
>   rtx i2dest = 0, i2src = 0, i1dest = 0, i1src = 0, i0dest = 0, i0src = 0;
> -  /* Copy of SET_SRC of I1, if needed.  */
> -  rtx i1src_copy = 0;
> +  /* Copy of SET_SRC of I1 and I0, if needed.  */
> +  rtx i1src_copy = 0, i0src_copy = 0, i0src_copy2 = 0;
>   /* Set if I2DEST was reused as a scratch register.  */
>   bool i2scratch = false;
>   /* The PATTERNs of I0, I1, and I2, or a copy of them in certain cases.  */
> @@ -3164,6 +3164,11 @@
>       n_occurrences = 0;
>       subst_low_luid = DF_INSN_LUID (i1);
>
> +      /* If the following substitution will modify I1SRC, make a copy of it
> +        for the case where it is substituted for I1DEST in I2PAT later.  */
> +      if (added_sets_2 && i1_feeds_i2_n)
> +       i1src_copy = copy_rtx (i1src);
> +
>       /* If I0 feeds into I1 and I0DEST is in I0SRC, we need to make a unique
>         copy of I1SRC each time we substitute it, in order to avoid creating
>         self-referential RTL when we will be substituting I0SRC for I0DEST
> @@ -3191,10 +3196,14 @@
>          return 0;
>        }
>
> -      /* If the following substitution will modify I1SRC, make a copy of it
> -        for the case where it is substituted for I1DEST in I2PAT later.  */
> -      if (i0_feeds_i1_n && added_sets_2 && i1_feeds_i2_n)
> -       i1src_copy = copy_rtx (i1src);
> +      /* If the following substitution will modify I0SRC, make a copy of it
> +        for the case where it is substituted for I0DEST in I1PAT later.  */
> +      if (added_sets_1 && i0_feeds_i1_n)
> +       i0src_copy = copy_rtx (i0src);
> +      /* And a copy for I0DEST in I2PAT substitution.  */
> +      if (added_sets_2 && ((i0_feeds_i1_n && i1_feeds_i2_n)
> +                          || (i0_feeds_i2_n)))
> +       i0src_copy2 = copy_rtx (i0src);
>
>       n_occurrences = 0;
>       subst_low_luid = DF_INSN_LUID (i0);
> @@ -3260,7 +3269,7 @@
>        {
>          rtx t = i1pat;
>          if (i0_feeds_i1_n)
> -           t = subst (t, i0dest, i0src, 0, 0);
> +           t = subst (t, i0dest, i0src_copy ? i0src_copy : i0src, 0, 0);
>
>          XVECEXP (newpat, 0, --total_sets) = t;
>        }
> @@ -3271,7 +3280,7 @@
>            t = subst (t, i1dest, i1src_copy ? i1src_copy : i1src, 0,
>                       i0_feeds_i1_n && i0dest_in_i0src);
>          if ((i0_feeds_i1_n && i1_feeds_i2_n) || i0_feeds_i2_n)
> -           t = subst (t, i0dest, i0src, 0, 0);
> +           t = subst (t, i0dest, i0src_copy2 ? i0src_copy2 : i0src, 0, 0);
>
>          XVECEXP (newpat, 0, --total_sets) = t;
>        }
>
> --
> This patch is available for review at http://codereview.appspot.com/5712053



More information about the Gcc-patches mailing list