[gcc r8-10473] if-conv: Fix -fcompare-debug bugs in ifcvt_local_dce [PR94283]
Jakub Jelinek
jakub@gcc.gnu.org
Thu Sep 17 14:25:44 GMT 2020
https://gcc.gnu.org/g:c9790fa67882765eb293774e629cd071de857952
commit r8-10473-gc9790fa67882765eb293774e629cd071de857952
Author: Jakub Jelinek <jakub@redhat.com>
Date: Tue Apr 7 20:57:37 2020 +0200
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.
(cherry picked from commit 4dcfd4e56b0d22af12750372f3e0b49249b1d473)
Diff:
---
gcc/testsuite/gcc.target/i386/pr94283.c | 5 +++++
gcc/tree-if-conv.c | 14 ++++++++------
2 files changed, 13 insertions(+), 6 deletions(-)
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 d205e605a63..dd9bf469730 100644
--- a/gcc/tree-if-conv.c
+++ b/gcc/tree-if-conv.c
@@ -2755,9 +2755,12 @@ ifcvt_local_dce (basic_block bb)
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);
@@ -2778,7 +2781,7 @@ ifcvt_local_dce (basic_block bb)
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);
@@ -2801,8 +2804,7 @@ ifcvt_local_dce (basic_block bb)
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