aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2023-02-17 14:21:39 +0100
committerRichard Biener <rguenther@suse.de>2023-02-20 08:44:16 +0100
commitca31bc3366c533a55bfd7f1b9f4959c0c9869a7b (patch)
tree3fa70d047339b95e2fd8a31910c0a081a9ece7b8
parent6e16c354f5dee8c3d8a59a5412d548e94cd5cfce (diff)
downloadgcc-ca31bc3366c533a55bfd7f1b9f4959c0c9869a7b.zip
gcc-ca31bc3366c533a55bfd7f1b9f4959c0c9869a7b.tar.gz
gcc-ca31bc3366c533a55bfd7f1b9f4959c0c9869a7b.tar.bz2
tree-optimization/108819 - niter analysis ICE with unexpected constant
The following makes sure we do not ICE on unfolded stmts like _1 = 1 & 1. PR tree-optimization/108819 * tree-ssa-loop-niter.cc (number_of_iterations_cltz): Check we have an SSA name as iv_2 as expected.
-rw-r--r--gcc/tree-ssa-loop-niter.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/gcc/tree-ssa-loop-niter.cc b/gcc/tree-ssa-loop-niter.cc
index 581bf5d..1ce5e73 100644
--- a/gcc/tree-ssa-loop-niter.cc
+++ b/gcc/tree-ssa-loop-niter.cc
@@ -2354,7 +2354,8 @@ number_of_iterations_cltz (loop_p loop, edge exit,
gimple *and_stmt = SSA_NAME_DEF_STMT (gimple_cond_lhs (cond_stmt));
if (!is_gimple_assign (and_stmt)
|| gimple_assign_rhs_code (and_stmt) != BIT_AND_EXPR
- || !integer_pow2p (gimple_assign_rhs2 (and_stmt)))
+ || !integer_pow2p (gimple_assign_rhs2 (and_stmt))
+ || TREE_CODE (gimple_assign_rhs1 (and_stmt)) != SSA_NAME)
return false;
checked_bit = tree_log2 (gimple_assign_rhs2 (and_stmt));
@@ -2382,7 +2383,8 @@ number_of_iterations_cltz (loop_p loop, edge exit,
precision. */
iv_2 = gimple_assign_rhs1 (test_value_stmt);
tree rhs_type = TREE_TYPE (iv_2);
- if (TREE_CODE (rhs_type) != INTEGER_TYPE
+ if (TREE_CODE (iv_2) != SSA_NAME
+ || TREE_CODE (rhs_type) != INTEGER_TYPE
|| (TYPE_PRECISION (rhs_type)
!= TYPE_PRECISION (test_value_type)))
return false;