[Bug tree-optimization/98282] [8/9/10/11 Regression] Segmentation fault when compiling with optimization >= 2

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Jan 4 10:40:31 GMT 2021


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98282

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
So the classification as VN_REFERENCE is wrong.  We're doing

              case tcc_reference:
                /* VOP-less references can go through unary case.  */
                if ((code == REALPART_EXPR
                     || code == IMAGPART_EXPR
                     || code == VIEW_CONVERT_EXPR
                     || code == BIT_FIELD_REF)
                    && TREE_CODE (TREE_OPERAND (rhs1, 0)) == SSA_NAME)
                  return VN_NARY;

but do not expect "unfolded" constants to appear.  We're also classifying
&foo as VN_CONSTANT but I guess classifying V_C_E<0> as VN_CONSTANT will
have too many ripple-down effects.

Now another question is of course why we do not fold this conversion.

diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index e0a75636352..b39859dbc1b 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -543,7 +543,8 @@ vn_get_stmt_kind (gimple *stmt)
                     || code == IMAGPART_EXPR
                     || code == VIEW_CONVERT_EXPR
                     || code == BIT_FIELD_REF)
-                   && TREE_CODE (TREE_OPERAND (rhs1, 0)) == SSA_NAME)
+                   && (TREE_CODE (TREE_OPERAND (rhs1, 0)) == SSA_NAME
+                       || is_gimple_min_invariant (TREE_OPERAND (rhs1, 0))))
                  return VN_NARY;

                /* Fallthrough.  */


More information about the Gcc-bugs mailing list