From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 843783858C42; Wed, 21 Feb 2024 12:40:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 843783858C42 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1708519219; bh=WSngc/2RpDNSly20xy8i/1McOsyn7phheYge961Rk7I=; h=From:To:Subject:Date:In-Reply-To:References:From; b=VHq2g+kZu4bN7Zbkr4aKoKl2HWRtCQekYYVL5iJCQfD4d05DdCqji9+kCPVemzcrj VvDcd6y43qFrJbevG62cdpelYfCXnigp3aIq+ox2Xw3H+idsx3VsUzG9Wl0MG4YMFi Wc/iA1GlHS1tvhfskU90YC3U/KmFdPXTEOifJOBQ= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/113988] during GIMPLE pass: bitintlower: internal compiler error: in lower_stmt, at gimple-lower-bitint.cc:5470 Date: Wed, 21 Feb 2024 12:40:18 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D113988 --- Comment #17 from Jakub Jelinek --- So, I've tried --- gcc/gimple-lower-bitint.cc.jj 2024-02-15 09:52:40.999145971 +0100 +++ gcc/gimple-lower-bitint.cc 2024-02-21 12:48:38.704163901 +0100 @@ -5307,12 +5307,15 @@ bitint_large_huge::lower_stmt (gimple *s final_cast_p =3D true; if (TREE_CODE (TREE_TYPE (lhs)) =3D=3D INTEGER_TYPE && TYPE_PRECISION (TREE_TYPE (lhs)) > MAX_FIXED_MODE_SIZE - && gimple_assign_rhs_code (stmt) =3D=3D VIEW_CONVERT_EXPR) + && (gimple_assign_rhs_code (stmt) =3D=3D VIEW_CONVERT_EXPR + || (TYPE_PRECISION (TREE_TYPE (lhs)) + =3D=3D TYPE_PRECISION (TREE_TYPE (rhs1))))) { - /* Handle VIEW_CONVERT_EXPRs to not generally supported - huge INTEGER_TYPEs like uint256_t or uint512_t. These - are usually emitted from memcpy folding and backends - support moves with them but that is usually it. */ + /* Handle VIEW_CONVERT_EXPRs or same precision casts to not + generally supported huge INTEGER_TYPEs like uint256_t or + uint512_t. These are usually emitted from memcpy folding + and backends support moves with them but that is usually + it. */ if (TREE_CODE (rhs1) =3D=3D INTEGER_CST) { rhs1 =3D fold_unary (VIEW_CONVERT_EXPR, TREE_TYPE (lhs), @@ -5339,6 +5342,7 @@ bitint_large_huge::lower_stmt (gimple *s rhs1 =3D build1 (VIEW_CONVERT_EXPR, TREE_TYPE (lhs), m_vars[part]); gimple_assign_set_rhs1 (stmt, rhs1); + gimple_assign_set_rhs_code (stmt, VIEW_CONVERT_EXPR); } update_stmt (stmt); return; and while that fixes #c14 bar and qux, foo and baz still ICE, this time dur= ing expansion: pr113988.c: In function =E2=80=98foo=E2=80=99: pr113988.c:12:3: internal compiler error: in convert_move, at expr.cc:223 12 | __builtin_memcpy (p, &x, sizeof x); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 0x801435 convert_move(rtx_def*, rtx_def*, int) ../../gcc/expr.cc:223 0x826b99 expand_expr_real_2(separate_ops*, rtx_def*, machine_mode, expand_modifier) ../../gcc/expr.cc:9799 0x82c8f5 expand_expr_real_gassign(gassign*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool) ../../gcc/expr.cc:11096 0x82d4b2 expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool) ../../gcc/expr.cc:11277 0x825541 expand_expr_real(tree_node*, rtx_def*, machine_mode, expand_modifi= er, rtx_def**, bool) ../../gcc/expr.cc:9440 0x81a2df store_expr(tree_node*, rtx_def*, int, bool, bool) ../../gcc/expr.cc:6740 0x818717 expand_assignment(tree_node*, tree_node*, bool) ../../gcc/expr.cc:6461 The problem is that for bar/qux it is a VCE from an array, so nothing tries= to change it into something else, for e.g. foo bitintlower turns it into uint256_t _2; [local count: 1073741824]: _2 =3D VIEW_CONVERT_EXPR(x); MEM [(char * {ref-all})p_4(D)] =3D _2; where x is TREE_ADDRESSABLE _BitInt(256) PARM_DECL, but forwprop3 turns that into _2 =3D (uint256_t) x_1(D); and expansion isn't able to expand that (BLKmode PARM_DECL expanded as a MEM NOP_EXPR converted to OImode. So, either we could somehow handle that case during expansion (treat it basically as VCE), or tweak the /* For integral conversions with the same precision or pointer conversions use a NOP_EXPR instead. */ (simplify (view_convert @0) (if ((INTEGRAL_TYPE_P (type) || POINTER_TYPE_P (type)) && (INTEGRAL_TYPE_P (TREE_TYPE (@0)) || POINTER_TYPE_P (TREE_TYPE (@= 0))) && TYPE_PRECISION (type) =3D=3D TYPE_PRECISION (TREE_TYPE (@0))) (convert @0))) match.pd rule not to do that for INTEGER_TYPEs with PRECISION > MAX_FIXED_TYPE_PRECISION (then we don't need the gimple-lower-bitint.cc cha= nges either). --- gcc/match.pd.jj 2024-02-19 09:42:16.583617451 +0100 +++ gcc/match.pd 2024-02-21 13:32:06.567816298 +0100 @@ -4679,7 +4679,13 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (view_convert @0) (if ((INTEGRAL_TYPE_P (type) || POINTER_TYPE_P (type)) && (INTEGRAL_TYPE_P (TREE_TYPE (@0)) || POINTER_TYPE_P (TREE_TYPE (@0))) - && TYPE_PRECISION (type) =3D=3D TYPE_PRECISION (TREE_TYPE (@0))) + && TYPE_PRECISION (type) =3D=3D TYPE_PRECISION (TREE_TYPE (@0)) + /* Punt for conversions from or to barely supported huge + INTEGER_TYPEs. Those can handle just loads/stores/moves but + nothing else. */ + && (TYPE_PRECISION (type) <=3D MAX_FIXED_MODE_SIZE + || (TREE_CODE (type) !=3D INTEGER_TYPE + && TREE_CODE (TREE_TYPE (@0)) !=3D INTEGER_TYPE))) (convert @0))) /* Strip inner integral conversions that do not change precision or size, = or=