[pushed] backprop: Avoid double deletions [PR125579]
Checks
Commit Message
In this PR, two values were simplified to the same phi, which in
turn was made redundant by other simplifications. The pass then
tried to delete the phi twice.
Tested on powerpc64le-linux-gnu and x86_64-linux-gnu. Pushed as
obvious.
Richard
gcc/
PR tree-optimization/125579
* gimple-ssa-backprop.cc (backprop::execute): Avoid double deletions.
gcc/testsuite/
PR tree-optimization/125579
* gcc.dg/pr125579.c: New test.
---
gcc/gimple-ssa-backprop.cc | 4 +++-
gcc/testsuite/gcc.dg/pr125579.c | 16 ++++++++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gcc.dg/pr125579.c
@@ -1119,10 +1119,12 @@ backprop::execute ()
commit_replacement (v);
/* Phase 5: Remove any statements that might have become dead. */
+ auto_bitmap deleted_vars;
for (unsigned int i = 0; i < m_vars.length (); ++i)
if (var_info *v = m_vars[i])
if (TREE_CODE (v->new_value) == SSA_NAME
- && has_zero_uses (v->new_value))
+ && has_zero_uses (v->new_value)
+ && bitmap_set_bit (deleted_vars, SSA_NAME_VERSION (v->new_value)))
{
gimple *stmt = SSA_NAME_DEF_STMT (v->new_value);
gimple_stmt_iterator gsi = gsi_for_stmt (stmt);
new file mode 100644
@@ -0,0 +1,16 @@
+/* { dg-options "-w -O3 -fno-tree-ccp -fno-inline" } */
+
+int printf(const char *, ...);
+int a;
+void c(int d) {
+ unsigned e = 0;
+ if (a)
+ e = -(0 / (e * 0));
+ while (a) {
+ if (d)
+ continue;
+ printf("%d", e);
+ e++;
+ }
+}
+int main() { c(1); }