[gcc(refs/users/marxin/heads/vect_cond_expr-rework-v3)] if-conv: Fix -fcompare-debug bugs in ifcvt_local_dce [PR94283]
Martin Liska
marxin@gcc.gnu.org
Wed Mar 25 15:12:44 GMT 2020
https://gcc.gnu.org/g:a5a9400a846244d040caa6d1531434eee8fc8ec7
commit a5a9400a846244d040caa6d1531434eee8fc8ec7
Author: Jakub Jelinek <jakub@redhat.com>
Date: Tue Mar 24 09:34:58 2020 +0100
if-conv: Fix -fcompare-debug bugs in ifcvt_local_dce [PR94283]
The following testcase shows -fcompare-debug bugs in ifcvt_local_dce,
where the decisions what statements are needed is based also on debug stmt
operands, which is wrong.
So, this patch makes sure to never add debug stmt to the worklist, or never
add an assign to worklist just because it is used in a debug stmt in another
bb.
2020-03-24 Jakub Jelinek <jakub@redhat.com>
PR debug/94283
* tree-if-conv.c (ifcvt_local_dce): For gimple debug stmts, just set
GF_PLF_2, but don't add them to worklist. Don't add an assigment to
worklist or set GF_PLF_2 just because it is used in a debug stmt in
another bb. Formatting improvements.
* gcc.target/i386/pr94283.c: New test.
Diff:
---
gcc/ChangeLog | 6 ++++++
gcc/testsuite/ChangeLog | 3 +++
gcc/testsuite/gcc.target/i386/pr94283.c | 5 +++++
gcc/tree-if-conv.c | 14 ++++++++------
4 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index a45d7ba876b..51cb52dbb10 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,11 @@
2020-03-24 Jakub Jelinek <jakub@redhat.com>
+ PR debug/94283
+ * tree-if-conv.c (ifcvt_local_dce): For gimple debug stmts, just set
+ GF_PLF_2, but don't add them to worklist. Don't add an assigment to
+ worklist or set GF_PLF_2 just because it is used in a debug stmt in
+ another bb. Formatting improvements.
+
PR debug/94277
* cgraphunit.c (check_global_declaration): For DECL_EXTERNAL and
non-TREE_PUBLIC non-DECL_ARTIFICIAL FUNCTION_DECLs, set TREE_PUBLIC
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 13e60901580..e050d159d5c 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2020-03-24 Jakub Jelinek <jakub@redhat.com>
+ PR debug/94283
+ * gcc.target/i386/pr94283.c: New test.
+
PR debug/94277
* gcc.dg/pr94277.c: New test.
diff --git a/gcc/testsuite/gcc.target/i386/pr94283.c b/gcc/testsuite/gcc.target/i386/pr94283.c
new file mode 100644
index 00000000000..4982f7d01d7
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr94283.c
@@ -0,0 +1,5 @@
+/* PR debug/94283 */
+/* { dg-do compile } */
+/* { dg-options "-O3 -fcompare-debug -mavx2" } */
+
+#include "../../gcc.dg/fold-bopcond-1.c"
diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c
index 8d24c18d5de..dd11d805c77 100644
--- a/gcc/tree-if-conv.c
+++ b/gcc/tree-if-conv.c
@@ -2917,9 +2917,12 @@ ifcvt_local_dce (class loop *loop)
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
{
stmt = gsi_stmt (gsi);
- if (gimple_store_p (stmt)
- || gimple_assign_load_p (stmt)
- || is_gimple_debug (stmt))
+ if (is_gimple_debug (stmt))
+ {
+ gimple_set_plf (stmt, GF_PLF_2, true);
+ continue;
+ }
+ if (gimple_store_p (stmt) || gimple_assign_load_p (stmt))
{
gimple_set_plf (stmt, GF_PLF_2, true);
worklist.safe_push (stmt);
@@ -2940,7 +2943,7 @@ ifcvt_local_dce (class loop *loop)
FOR_EACH_IMM_USE_FAST (use_p, imm_iter, lhs)
{
stmt1 = USE_STMT (use_p);
- if (gimple_bb (stmt1) != bb)
+ if (!is_gimple_debug (stmt1) && gimple_bb (stmt1) != bb)
{
gimple_set_plf (stmt, GF_PLF_2, true);
worklist.safe_push (stmt);
@@ -2963,8 +2966,7 @@ ifcvt_local_dce (class loop *loop)
if (TREE_CODE (use) != SSA_NAME)
continue;
stmt1 = SSA_NAME_DEF_STMT (use);
- if (gimple_bb (stmt1) != bb
- || gimple_plf (stmt1, GF_PLF_2))
+ if (gimple_bb (stmt1) != bb || gimple_plf (stmt1, GF_PLF_2))
continue;
gimple_set_plf (stmt1, GF_PLF_2, true);
worklist.safe_push (stmt1);
More information about the Gcc-cvs
mailing list