From: Jakub Jelinek <jakub@redhat.com>
To: Jeff Law <law@redhat.com>, Richard Biener <rguenther@suse.de>,
Eric Botcazou <ebotcazou@libertysurf.fr>
Cc: gcc-patches@gcc.gnu.org
Subject: [PATCH] Perform cfg cleanup in cse if needed (PR rtl-optimization/92610)
Date: Sat, 23 Nov 2019 02:11:00 -0000 [thread overview]
Message-ID: <20191123011536.GI2466@tucnak> (raw)
Hi!
cse_main which sets tem has:
if (cse_jumps_altered || recorded_label_ref)
return 2;
else if (cse_cfg_altered)
return 1;
else
return 0;
at the end, but after these two functions call it, they call also
delete_trivially_dead_insns. Even when cse_main didn't need cfg changes,
delete_trivially_dead_insns could remove a trivially dead insn that had
EH edges and so we might still need to remove unreachable blocks.
The following patch implements it. Bootstrapped/regtested on x86_64-linux
and i686-linux, ok for trunk?
2019-11-23 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/92610
* cse.c (rest_of_handle_cse2): Call cleanup_cfg (0) also if
cse_cfg_altered is set, even when tem is 0.
(rest_of_handle_cse_after_global_opts): Likewise.
* g++.dg/opt/pr92610.C: New test.
--- gcc/cse.c.jj 2019-11-19 22:27:01.960059340 +0100
+++ gcc/cse.c 2019-11-22 15:51:34.639806155 +0100
@@ -7701,7 +7701,7 @@ rest_of_handle_cse2 (void)
cse_cfg_altered |= cleanup_cfg (CLEANUP_CFG_CHANGED);
timevar_pop (TV_JUMP);
}
- else if (tem == 1)
+ else if (tem == 1 || cse_cfg_altered)
cse_cfg_altered |= cleanup_cfg (0);
cse_not_expected = 1;
@@ -7775,7 +7775,7 @@ rest_of_handle_cse_after_global_opts (vo
cse_cfg_altered |= cleanup_cfg (CLEANUP_CFG_CHANGED);
timevar_pop (TV_JUMP);
}
- else if (tem == 1)
+ else if (tem == 1 || cse_cfg_altered)
cse_cfg_altered |= cleanup_cfg (0);
flag_cse_follow_jumps = save_cfj;
--- gcc/testsuite/g++.dg/opt/pr92610.C.jj 2019-11-22 15:52:46.254734331 +0100
+++ gcc/testsuite/g++.dg/opt/pr92610.C 2019-11-22 15:53:14.991303498 +0100
@@ -0,0 +1,13 @@
+// PR rtl-optimization/92610
+// { dg-do compile }
+// { dg-options "-w -fdelete-dead-exceptions --param=sccvn-max-alias-queries-per-access=0 -fno-dse -fnon-call-exceptions -Os -funroll-loops -ftrapv" }
+
+struct C { int x; ~C () {} };
+
+int
+main ()
+{
+ C *buffer = new C[42];
+ buffer[-3].x = 42;
+ delete [] buffer;
+}
Jakub
next reply other threads:[~2019-11-23 1:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-23 2:11 Jakub Jelinek [this message]
2019-11-23 6:56 ` Richard Biener
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=20191123011536.GI2466@tucnak \
--to=jakub@redhat.com \
--cc=ebotcazou@libertysurf.fr \
--cc=gcc-patches@gcc.gnu.org \
--cc=law@redhat.com \
--cc=rguenther@suse.de \
/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).