https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89779
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |88945 --- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> --- So we fail to run into the defensive static inline bool tree_nop_conversion (const_tree exp) { ... inner_type = TREE_TYPE (TREE_OPERAND (exp, 0)); if (!inner_type) return false; now because the type is not NULL but error_mark_node. Of course the real issue is that we are operating on trees with released SSA names at all. The above is from r158045 2010-04-07 Richard Guenther <rguent...@suse.de> PR middle-end/42617 * emit-rtl.c (set_mem_attributes_minus_bitpos): Do not discard plain indirect references. * fold-const.c (operand_equal_p): Guard against NULL_TREE type. * tree.c (tree_nop_conversion): Likewise. where the tree_nop_conversion already has other defenses: if (TREE_OPERAND (exp, 0) == error_mark_node) return false; we can consolidate those checks now. Index: gcc/tree.c =================================================================== --- gcc/tree.c (revision 269832) +++ gcc/tree.c (working copy) @@ -12812,13 +12812,10 @@ tree_nop_conversion (const_tree exp) if (!CONVERT_EXPR_P (exp) && TREE_CODE (exp) != NON_LVALUE_EXPR) return false; - if (TREE_OPERAND (exp, 0) == error_mark_node) - return false; outer_type = TREE_TYPE (exp); inner_type = TREE_TYPE (TREE_OPERAND (exp, 0)); - - if (!inner_type) + if (inner_type == error_mark_node) return false; return tree_nop_conversion_p (outer_type, inner_type); Index: gcc/fold-const.c =================================================================== --- gcc/fold-const.c (revision 269832) +++ gcc/fold-const.c (working copy) @@ -2973,11 +2973,6 @@ operand_equal_p (const_tree arg0, const_ || TREE_TYPE (arg1) == error_mark_node) return 0; - /* Similar, if either does not have a type (like a released SSA name), - they aren't equal. */ - if (!TREE_TYPE (arg0) || !TREE_TYPE (arg1)) - return 0; - /* We cannot consider pointers to different address space equal. */ if (POINTER_TYPE_P (TREE_TYPE (arg0)) && POINTER_TYPE_P (TREE_TYPE (arg1)) The underlying issue is that IVOPTs removes unused IVs but keeps loop->control_ivs uncleared (it clears the SCEV cache which also resets loop->nb_iterations). The best fix for IVOPTs is probably to simply delay removal of those IVs and also properly free control-iv information. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88945 [Bug 88945] ICE in fold_convert_loc in FRE when using -fdump-tree-fre-details