[PATCH] Fix cc_use tweaks in combiner (PR rtl-optimization/38774)

Richard Guenther richard.guenther@gmail.com
Tue Jan 13 22:42:00 GMT 2009


On Tue, Jan 13, 2009 at 11:29 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> When simplify_set contemplates changing the CC using comparison in
> *cc_use, but then decides not to do that, *cc_use remains the newly
> created comparison, but with the old code, i.e. it is rtx_equal_p
> with the old one, but not the same pointer.  As in this case the
> other insn possibly won't have df_rescan_insn called on it, this
> confuses df.
>
> Fixed by restoring the old rtx pointer instead.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

Ok.

Thanks,
Richard.

> 2009-01-13  Jakub Jelinek  <jakub@redhat.com>
>
>        PR rtl-optimization/38774
>        * combine.c (simplify_set): When undoing cc_use change, don't do
>        PUT_CODE on the newly created comparison, but instead put back the
>        old comparison.
>
>        * gcc.dg/torture/pr38774.c: New test.
>
> --- gcc/combine.c.jj    2009-01-13 18:32:17.000000000 +0100
> +++ gcc/combine.c       2009-01-13 21:50:41.000000000 +0100
> @@ -5706,6 +5706,7 @@ simplify_set (rtx x)
>        {
>          int other_changed_previously = other_changed;
>          unsigned HOST_WIDE_INT mask;
> +         rtx old_cc_use = *cc_use;
>
>          SUBST (*cc_use, gen_rtx_fmt_ee (new_code, GET_MODE (*cc_use),
>                                          dest, const0_rtx));
> @@ -5728,7 +5729,7 @@ simplify_set (rtx x)
>              if ((recog_for_combine (&pat, other_insn, &note) < 0
>                   && ! check_asm_operands (pat)))
>                {
> -                 PUT_CODE (*cc_use, old_code);
> +                 *cc_use = old_cc_use;
>                  other_changed = 0;
>
>                  op0 = simplify_gen_binary (XOR, GET_MODE (op0),
> --- gcc/testsuite/gcc.dg/torture/pr38774.c.jj   2009-01-13 21:53:10.000000000 +0100
> +++ gcc/testsuite/gcc.dg/torture/pr38774.c      2009-01-13 21:53:01.000000000 +0100
> @@ -0,0 +1,16 @@
> +/* PR rtl-optimization/38774 */
> +/* { dg-do compile } */
> +/* { dg-options "" } */
> +/* { dg-options "-march=i686" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
> +
> +extern int bar (void);
> +volatile int g;
> +
> +int
> +foo (void)
> +{
> +  int a = 1 >= bar ();
> +  if ((1 > 9223372036854775807LL - a && 1 - a ? : 1 + a) & 1)
> +    return g;
> +  return 0;
> +}
>
>        Jakub
>



More information about the Gcc-patches mailing list