[gcc(refs/users/mikael/heads/refactor_descriptor_v05)] Correction régressions transfer_simplify_*
Mikael Morin
mikael@gcc.gnu.org
Fri Jun 13 14:57:20 GMT 2025
https://gcc.gnu.org/g:6c328e13567e5e388814794552dca3a381396482
commit 6c328e13567e5e388814794552dca3a381396482
Author: Mikael Morin <mikael@gcc.gnu.org>
Date: Mon Apr 21 17:27:45 2025 +0200
Correction régressions transfer_simplify_*
Diff:
---
gcc/tree-ssa-loop-niter.cc | 7 ++++---
gcc/tree.cc | 12 +++++++++++-
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/gcc/tree-ssa-loop-niter.cc b/gcc/tree-ssa-loop-niter.cc
index 0fa9388594bc..9d352da8b2a0 100644
--- a/gcc/tree-ssa-loop-niter.cc
+++ b/gcc/tree-ssa-loop-niter.cc
@@ -3926,8 +3926,8 @@ do_warn_aggressive_loop_optimizations (class loop *loop,
known constant bound. */
|| wi::cmpu (i_bound, wi::to_widest (loop->nb_iterations)) >= 0
/* And undefined behavior happens unconditionally. */
- || !dominated_by_p (CDI_DOMINATORS, loop->latch, gimple_bb (stmt))
- || loop->latch == gimple_bb (stmt))
+ || !(dominated_by_p (CDI_DOMINATORS, loop->latch, gimple_bb (stmt))
+ || loop->latch == gimple_bb (stmt)))
return;
edge e = single_exit (loop);
@@ -4004,7 +4004,8 @@ record_estimate (class loop *loop, tree bound, const widest_int &i_bound,
/* If statement is executed on every path to the loop latch, we can directly
infer the upper bound on the # of iterations of the loop. */
- if (!dominated_by_p (CDI_DOMINATORS, loop->latch, gimple_bb (at_stmt)))
+ if (!(dominated_by_p (CDI_DOMINATORS, loop->latch, gimple_bb (at_stmt)))
+ || loop->latch == gimple_bb (at_stmt))
upper = false;
/* Update the number of iteration estimates according to the bound.
diff --git a/gcc/tree.cc b/gcc/tree.cc
index c8b8b3edd35a..fa5df47e8111 100644
--- a/gcc/tree.cc
+++ b/gcc/tree.cc
@@ -13046,7 +13046,17 @@ array_ref_up_bound (tree exp)
/* If there is a domain type and it has an upper bound, use it, substituting
for a PLACEHOLDER_EXPR as needed. */
if (domain_type && TYPE_MAX_VALUE (domain_type))
- return SUBSTITUTE_PLACEHOLDER_IN_EXPR (TYPE_MAX_VALUE (domain_type), exp);
+ {
+ tree val = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TYPE_MAX_VALUE (domain_type), exp);
+ if (TREE_OPERAND (exp, 2))
+ return fold_build2_loc (EXPR_LOCATION (exp), PLUS_EXPR,
+ TREE_TYPE (val), val,
+ fold_convert_loc (EXPR_LOCATION (exp),
+ TREE_TYPE (val),
+ TREE_OPERAND (exp, 2)));
+ else
+ return val;
+ }
/* Otherwise fail. */
return NULL_TREE;
More information about the Gcc-cvs
mailing list