From 62b0355332d6a102667074df1abf5e1a015809c6 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Wed, 12 Feb 2014 08:49:55 +0000 Subject: [PATCH] re PR rtl-optimization/60116 (wrong code at -Os on x86_64-linux-gnu in 32-bit mode) PR rtl-optimization/60116 * combine.c (try_combine): Also remove dangling REG_DEAD notes on the other_insn once the combination has been validated. From-SVN: r207713 --- gcc/ChangeLog | 6 +++ gcc/combine.c | 9 +++-- gcc/testsuite/ChangeLog | 4 ++ .../gcc.c-torture/execute/20140212-1.c | 37 +++++++++++++++++++ 4 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.c-torture/execute/20140212-1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9b501585f673..a92902bcb112 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2014-02-12 Eric Botcazou + + PR rtl-optimization/60116 + * combine.c (try_combine): Also remove dangling REG_DEAD notes on the + other_insn once the combination has been validated. + 2014-02-11 Jan Hubicka PR lto/59468 diff --git a/gcc/combine.c b/gcc/combine.c index fd4294bdd639..f6e1dbc46867 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -3894,14 +3894,15 @@ try_combine (rtx i3, rtx i2, rtx i1, rtx i0, int *new_direct_jump_p, PATTERN (undobuf.other_insn) = other_pat; - /* If any of the notes in OTHER_INSN were REG_UNUSED, ensure that they - are still valid. Then add any non-duplicate notes added by - recog_for_combine. */ + /* If any of the notes in OTHER_INSN were REG_DEAD or REG_UNUSED, + ensure that they are still valid. Then add any non-duplicate + notes added by recog_for_combine. */ for (note = REG_NOTES (undobuf.other_insn); note; note = next) { next = XEXP (note, 1); - if (REG_NOTE_KIND (note) == REG_UNUSED + if ((REG_NOTE_KIND (note) == REG_DEAD + || REG_NOTE_KIND (note) == REG_UNUSED) && ! reg_set_p (XEXP (note, 0), PATTERN (undobuf.other_insn))) remove_note (undobuf.other_insn, note); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2505b6a58822..5555d3edb7b5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2014-02-12 Eric Botcazou + + * gcc.c-torture/execute/20140212-1.c: New test. + 2014-02-12 Paolo Carlini PR c++/60047 diff --git a/gcc/testsuite/gcc.c-torture/execute/20140212-1.c b/gcc/testsuite/gcc.c-torture/execute/20140212-1.c new file mode 100644 index 000000000000..8f1f84f3e3cf --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/20140212-1.c @@ -0,0 +1,37 @@ +/* PR rtl-optimization/60116 */ +/* Reported by Zhendong Su */ + +extern void abort (void); + +int a, b, c, d = 1, e, f = 1, h, i, k; +char g, j; + +void +fn1 (void) +{ + int l; + e = 0; + c = 0; + for (;;) + { + k = a && b; + j = k * 54; + g = j * 147; + l = ~g + (long long) e && 1; + if (d) + c = l; + else + h = i = l * 9UL; + if (f) + return; + } +} + +int +main (void) +{ + fn1 (); + if (c != 1) + abort (); + return 0; +} -- 2.47.3