https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98514
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-10 branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:8d2e64c4a2892ca8889002b1a3dd713471ef9fab commit r10-9225-g8d2e64c4a2892ca8889002b1a3dd713471ef9fab Author: Jakub Jelinek <ja...@redhat.com> Date: Tue Jan 5 16:37:40 2021 +0100 reassoc: Fix reassociation on 32-bit hosts with > 32767 bbs [PR98514] Apparently reassoc ICEs on large functions (more than 32767 basic blocks with something to reassociate in those). The problem is that the pass uses long type to store the ranks, and the bb ranks are (number of SSA_NAMEs with default defs + 2 + bb->index) << 16, so with many basic blocks we overflow the ranks and we then have assertions rank is not negative. The following patch just uses int64_t instead of long in the pass, yes, it means slightly higher memory consumption (one array indexed by bb->index is twice as large, and one hash_map from trees to the ranks will grow by 50%, but I think it is better than punting on large functions the reassociation on 32-bit hosts and making it inconsistent e.g. when cross-compiling. Given vec.h uses unsigned for vect element counts, we don't really support more than 4G of SSA_NAMEs or more than 2G of basic blocks in a function, so even with the << 16 we can't really overflow the int64_t rank counters. 2021-01-05 Jakub Jelinek <ja...@redhat.com> PR tree-optimization/98514 * tree-ssa-reassoc.c (bb_rank): Change type from long * to int64_t *. (operand_rank): Change type from hash_map<tree, long> to hash_map<tree, int64_t>. (phi_rank): Change return type from long to int64_t. (loop_carried_phi): Change block_rank variable type from long to int64_t. (propagate_rank): Change return type, rank parameter type and op_rank variable type from long to int64_t. (find_operand_rank): Change return type from long to int64_t and change slot variable type from long * to int64_t *. (insert_operand_rank): Change rank parameter type from long to int64_t. (get_rank): Change return type and rank variable type from long to int64_t. Use PRId64 instead of ld to print the rank. (init_reassoc): Change rank variable type from long to int64_t and adjust correspondingly bb_rank and operand_rank initialization. (cherry picked from commit 4ddee425b8c427d3cc13c49b26f442313e239572)