diff --git a/gcc/ChangeLog b/gcc/ChangeLog index bc43ad231f1..6821c91516d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2014-03-20 Jakub Jelinek + PR middle-end/60597 + * ira.c (adjust_cleared_regs): Call copy_rtx on + *reg_equiv[REGNO (loc)].src_p before passing it to + simplify_replace_fn_rtx. + PR target/60568 * config/i386/i386.c (x86_output_mi_thunk): Surround UNSPEC_GOT into CONST, put pic register as first operand of PLUS. Use diff --git a/gcc/ira.c b/gcc/ira.c index 7c49b7f6b74..4d91d2196a6 100644 --- a/gcc/ira.c +++ b/gcc/ira.c @@ -3428,7 +3428,7 @@ adjust_cleared_regs (rtx loc, const_rtx old_rtx ATTRIBUTE_UNUSED, void *data) { bitmap cleared_regs = (bitmap) data; if (bitmap_bit_p (cleared_regs, REGNO (loc))) - return simplify_replace_fn_rtx (*reg_equiv[REGNO (loc)].src_p, + return simplify_replace_fn_rtx (copy_rtx (*reg_equiv[REGNO (loc)].src_p), NULL_RTX, adjust_cleared_regs, data); } return NULL_RTX; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3cadcfea47c..2475787808c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2014-03-20 Jakub Jelinek + PR middle-end/60597 + * g++.dg/opt/pr60597.C: New test. + PR c++/60572 * g++.dg/init/pr60572.C: New test. diff --git a/gcc/testsuite/g++.dg/opt/pr60597.C b/gcc/testsuite/g++.dg/opt/pr60597.C new file mode 100644 index 00000000000..c61f7679765 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/pr60597.C @@ -0,0 +1,46 @@ +// PR middle-end/60597 +// { dg-do compile } +// { dg-options "-O2 -g" } + +struct A +{ + int foo () const; + int bar () const; + int a; +}; + +struct B +{ + int foo (); + int bar (); +}; + +int *c, d; + +int +A::foo () const +{ + int b = a >> 16; + return b; +} + +int +A::bar () const +{ + int b = a; + return b; +} + +void +baz (A &x, B h, int i, int j) +{ + for (; i < h.bar (); ++i) + for (; h.foo (); ++j) + { + int g = x.foo (); + int f = x.bar (); + int e = c[0] & 1; + d = (e << 1) | (g << 16) | (f & 1); + c[j] = 0; + } +}