aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-phiopt.cc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2023-12-09 21:41:00 +0100
committerJakub Jelinek <jakub@redhat.com>2023-12-09 21:41:00 +0100
commitc250ff90989a71dff11e9256e99d2fa965ab1295 (patch)
treeec2475450ac573db4df6026f80a401426de10a12 /gcc/tree-ssa-phiopt.cc
parentaf8bbd631f5425e9be084dfd1f2b9487a31a350e (diff)
downloadgcc-c250ff90989a71dff11e9256e99d2fa965ab1295.zip
gcc-c250ff90989a71dff11e9256e99d2fa965ab1295.tar.gz
gcc-c250ff90989a71dff11e9256e99d2fa965ab1295.tar.bz2
phiopt: Fix ICE with large --param l1-cache-line-size= [PR112887]
This function is never called when param_l1_cache_line_size is 0, but it uses int and unsigned int variables to hold alignment in bits, so for large param_l1_cache_line_size it is zero and e.g. DECL_ALIGN () % param_align_bits can divide by zero. Looking at the code, the function uses tree_fits_uhwi_p on the trees before converting them using tree_to_uhwi to int variables, which looks just wrong, either it would need to punt if it doesn't fit into those and also check for overflows during the computation, or use unsigned HOST_WIDE_INT for all of this. That also fixes the division by zero, as param_l1_cache_line_size maximum is INT_MAX, that multiplied by 8 will always fit. 2023-12-09 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/112887 * tree-ssa-phiopt.cc (hoist_adjacent_loads): Change type of param_align, param_align_bits, offset1, offset2, size2 and align1 variables from int or unsigned int to unsigned HOST_WIDE_INT. * gcc.dg/pr112887.c: New test.
Diffstat (limited to 'gcc/tree-ssa-phiopt.cc')
-rw-r--r--gcc/tree-ssa-phiopt.cc7
1 files changed, 3 insertions, 4 deletions
diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc
index ac80517..a3b660b 100644
--- a/gcc/tree-ssa-phiopt.cc
+++ b/gcc/tree-ssa-phiopt.cc
@@ -3757,8 +3757,8 @@ static void
hoist_adjacent_loads (basic_block bb0, basic_block bb1,
basic_block bb2, basic_block bb3)
{
- int param_align = param_l1_cache_line_size;
- unsigned param_align_bits = (unsigned) (param_align * BITS_PER_UNIT);
+ unsigned HOST_WIDE_INT param_align = param_l1_cache_line_size;
+ unsigned HOST_WIDE_INT param_align_bits = param_align * BITS_PER_UNIT;
gphi_iterator gsi;
/* Walk the phis in bb3 looking for an opportunity. We are looking
@@ -3770,8 +3770,7 @@ hoist_adjacent_loads (basic_block bb0, basic_block bb1,
gimple *def1, *def2;
tree arg1, arg2, ref1, ref2, field1, field2;
tree tree_offset1, tree_offset2, tree_size2, next;
- int offset1, offset2, size2;
- unsigned align1;
+ unsigned HOST_WIDE_INT offset1, offset2, size2, align1;
gimple_stmt_iterator gsi2;
basic_block bb_for_def1, bb_for_def2;