From: Alan Modra <amodra@gmail.com>
To: gcc-patches@gcc.gnu.org
Subject: Re: PR79286, ira combine_and_move_insns in loops
Date: Thu, 02 Feb 2017 09:31:00 -0000 [thread overview]
Message-ID: <20170202093138.GF3731@bubble.grove.modra.org> (raw)
In-Reply-To: <20170201213722.GB3731@bubble.grove.modra.org>
Revised patch that cures the lra related -m32 -Os regression too.
The code that I'm patching here is changing a REG_EQUAL note to
REG_EQUIV, ie. asserting that the value of the reg is always the value
set by the current instruction. Which is not always true when the
insn is in a loop and the use of the reg happens before the def. Of
course that implies the value of the reg is initially undefined, so
it's not unreasonable to make the initial reg value the same.
Except when the code setting the initial value may trap, as it does in
the testcase.
Bootstrap and regression test on x86_64-linux in progress. OK
assuming no regressions?
I also took a look at gcc/*.o to see whether there were any code
quality regressions. No differences found except the expected change
in ira.o.
PR rtl-optimization/79286
* ira.c (update_equiv_regs): Do not create an equivalence for
mems that may trap.
testsuite/
* gcc.c-torture/execute/pr79286.c: New.
diff --git a/gcc/ira.c b/gcc/ira.c
index 96b4b62..8e79929 100644
--- a/gcc/ira.c
+++ b/gcc/ira.c
@@ -3500,7 +3500,9 @@ update_equiv_regs (void)
/* If this register is known to be equal to a constant, record that
it is always equivalent to the constant. */
if (DF_REG_DEF_COUNT (regno) == 1
- && note && ! rtx_varies_p (XEXP (note, 0), 0))
+ && note
+ && !rtx_varies_p (XEXP (note, 0), 0)
+ && !may_trap_p (XEXP (note, 0)))
{
rtx note_value = XEXP (note, 0);
remove_note (insn, note);
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr79286.c b/gcc/testsuite/gcc.c-torture/execute/pr79286.c
new file mode 100644
index 0000000..e6d0e93
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr79286.c
@@ -0,0 +1,15 @@
+int a = 0, c = 0;
+static int d[][8] = {};
+
+int main ()
+{
+ int e;
+ for (int b = 0; b < 4; b++)
+ {
+ __builtin_printf ("%d\n", b, e);
+ while (a && c++)
+ e = d[300000000000000000][0];
+ }
+
+ return 0;
+}
--
Alan Modra
Australia Development Lab, IBM
next prev parent reply other threads:[~2017-02-02 9:31 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-01 13:48 Alan Modra
2017-02-01 21:37 ` Alan Modra
2017-02-02 9:31 ` Alan Modra [this message]
2017-02-03 8:55 ` Jeff Law
2017-02-11 0:52 ` Alan Modra
2017-02-16 23:08 ` Jeff Law
2017-02-04 0:08 ` Jeff Law
2017-02-18 14:28 Dominique d'Humières
2017-02-21 23:35 ` Alan Modra
2017-02-22 12:10 ` Dominique d'Humières
2017-02-22 16:32 ` Jeff Law
2017-02-22 16:57 ` Dominique d'Humières
2017-02-23 8:55 ` Jeff Law
2017-02-23 10:13 ` Alan Modra
2017-02-23 15:22 ` Jeff Law
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170202093138.GF3731@bubble.grove.modra.org \
--to=amodra@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).