When match-and-simplify simplification fails we have to release
eventually pushed stmts.
Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.
PR middle-end/125146
* gimple-fold.cc (fold_stmt_1): Discard stmts in seq
after failed gimple_simplify as well.
---
gcc/gimple-fold.cc | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc
index b53478dbb3d..8f9119f2469 100644
--- a/gcc/gimple-fold.cc
+++ b/gcc/gimple-fold.cc
@@ -6885,14 +6885,12 @@ fold_stmt_1 (gimple_stmt_iterator *gsi, bool inplace,
tree (*valueize) (tree),
gimple_seq seq = NULL;
gimple_match_op res_op;
if (gimple_simplify (stmt, &res_op, inplace ? NULL : &seq,
- valueize, valueize))
- {
- if (replace_stmt_with_simplification (gsi, &res_op, &seq, inplace,
- dce_worklist))
- changed = true;
- else
- gimple_seq_discard (seq);
- }
+ valueize, valueize)
+ && replace_stmt_with_simplification (gsi, &res_op, &seq, inplace,
+ dce_worklist))
+ changed = true;
+ else
+ gimple_seq_discard (seq);
}
stmt = gsi_stmt (*gsi);
--
2.51.0