From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 424C538930D6; Mon, 8 Feb 2021 08:45:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 424C538930D6 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: =?UTF-8?B?W0J1ZyBsdG8vOTY1OTFdIFs4LzkvMTAvMTEgUmVncmVzc2lvbl0g?= =?UTF-8?B?SUNFIHdpdGggLWZsdG89YXV0byBhbmQgLU8xOiB0cmVlIGNvZGUg4oCYdHlw?= =?UTF-8?B?ZW5hbWVfdHlwZeKAmSBpcyBub3Qgc3VwcG9ydGVkIGluIExUTyBzdHJlYW1z?= Date: Mon, 08 Feb 2021 08:45:33 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: lto X-Bugzilla-Version: 10.1.1 X-Bugzilla-Keywords: lto X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: 8.5 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Feb 2021 08:45:35 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96591 --- Comment #7 from Richard Biener --- So the type is refered to by constant 8 which is refered to by a VECTOR_CST { 8 } which is refered to by # .MEM_4 =3D VDEF <.MEM_2> MEM[(struct Test *)_3].data[0] =3D { 8 }; and while walk_tree walks CTOR elements for VECTOR_CST it does nothing: switch (code) { case ERROR_MARK: case IDENTIFIER_NODE: case INTEGER_CST: case REAL_CST: case FIXED_CST: case VECTOR_CST: case STRING_CST: case BLOCK: case PLACEHOLDER_EXPR: case SSA_NAME: case FIELD_DECL: case RESULT_DECL: /* None of these have subtrees other than those already walked above. */ break; which is eventually true since we expect the element type of a VECTOR_CST to match that of the vector element type. _But_ - we're forcing a vector element type to be the main variant / canonical type: unit-size align:32 warn_if_not_align:0 symtab:0 alias-set 2 canonical-type 0x7ffff65885e8 precision:32 min max pointer_to_this > type_6 SI size unit-size align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7ffff66dedc8 nunits:1> constant npatterns:1 nelts-per-pattern:1 elt:0: constant 8>> (gdb) p ((tree)0x7ffff66de3f0)->type_common.canonical=20 $134 =3D (gdb) p ((tree)0x7ffff66de3f0)->type_common.main_variant=20 $135 =3D where we build this via #0 0x0000000001cf4437 in tree_vector_builder::build (this=3D0x7fffffffbfe0) at /home/rguenther/src/gcc3/gcc/tree-vector-builder.c:44 #1 0x0000000001d112c9 in build_vector_from_ctor ( type=3D, v=3D0x7ffff66e72d0 =3D {...}) at /home/rguenther/src/gcc3/gcc/tree.c:1969 #2 0x00000000012cccda in fold (expr=3D) at /home/rguenther/src/gcc3/gcc/fold-const.c:13383 #3 0x0000000000b0b893 in cxx_eval_bare_aggregate (ctx=3D0x7fffffffc290,=20 t=3D, lval=3Dfalse, non_constant_p=3D0x7fff= ffffd1bf,=20 overflow_p=3D0x7fffffffd1be) at /home/rguenther/src/gcc3/gcc/cp/constexpr.c:4438 #4 0x0000000000b14c6b in cxx_eval_constant_expression (ctx=3D0x7fffffffc61= 0,=20 t=3D, lval=3Dfalse, non_constant_p=3D0x7fff= ffffd1bf,=20 overflow_p=3D0x7fffffffd1be, jump_target=3D0x0) at /home/rguenther/src/gcc3/gcc/cp/constexpr.c:6591 it's tempting to try force the cached integer constants to be always unqualified so that only the TYPE_MAIN_VARIANT has TYPE_CACHED_VALUES and we save memory. The constant is built via (gdb) bt #0 0x0000000001d0fcf1 in cache_wide_int_in_type_cache ( type=3D, cst=3D..., slot=3D9,= =20 max_slots=3D252) at /home/rguenther/src/gcc3/gcc/tree.c:1535 #1 0x0000000001d1020d in wide_int_to_tree_1 ( type=3D, pcst=3D...) at /home/rguenther/src/gcc3/gcc/tree.c:1649 #2 0x0000000001d10878 in wide_int_to_tree ( type=3D, value=3D...) at /home/rguenther/src/gcc3/gcc/tree.c:1756 #3 0x0000000001d0f918 in force_fit_type ( type=3D, cst=3D..., overflowab= le=3D1,=20 overflowed=3Dfalse) at /home/rguenther/src/gcc3/gcc/tree.c:1474 #4 0x00000000012969cb in fold_convert_const_int_from_int ( type=3D,=20 arg1=3D) at /home/rguenther/src/gcc3/gcc/fold-const.c:2000 #5 0x00000000012988b6 in fold_convert_const (code=3DNOP_EXPR,=20 type=3D,=20 arg1=3D) at /home/rguenther/src/gcc3/gcc/fold-const.c:2276 #6 0x0000000001299214 in fold_convert_loc (loc=3D0,=20 type=3D,=20 arg=3D) --Type for more, q to quit, c to continue without paging-- at /home/rguenther/src/gcc3/gcc/fold-const.c:2418 #7 0x0000000000b714fa in cp_fold_convert ( type=3D,=20 expr=3D) at /home/rguenther/src/gcc3/gcc/cp/cvt.c:629 #8 0x0000000000aff0d3 in adjust_temp_type ( type=3D,=20 temp=3D) at /home/rguenther/src/gcc3/gcc/cp/constexpr.c:1501 #9 0x0000000000aff651 in cxx_bind_parameters_in_call (ctx=3D0x7fffffffd0a0= ,=20 t=3D, new_call=3D0x7fffffffccc0,=20 non_constant_p=3D0x7fffffffd1bf, overflow_p=3D0x7fffffffd1be,=20 non_constant_args=3D0x7fffffffcc7f) at /home/rguenther/src/gcc3/gcc/cp/constexpr.c:1611 #10 0x0000000000b0404c in cxx_eval_call_expression (ctx=3D0x7fffffffd0a0,=20 t=3D, lval=3Dfalse, non_constant_p=3D0x7fffff= ffd1bf,=20 overflow_p=3D0x7fffffffd1be) at /home/rguenther/src/gcc3/gcc/cp/constexpr.c:2536 #11 0x0000000000b13215 in cxx_eval_constant_expression (ctx=3D0x7fffffffd0a= 0,=20 t=3D, lval=3Dfalse, non_constant_p=3D0x7fffff= ffd1bf,=20 overflow_p=3D0x7fffffffd1be, jump_target=3D0x0) at /home/rguenther/src/gcc3/gcc/cp/constexpr.c:6134 where the constant is first built in the "correct" type and then converted via adjust_temp_type which does 1499 /* Now we know we're dealing with a scalar, and a prvalue of non-class 1500 type is cv-unqualified. */ 1501 return cp_fold_convert (cv_unqualified (type), temp); but that cv_unqualified doesn't produce the main variant. Now, as a fact walk_tree _does_ walk COMPLEX_CST components so the "obvious" fix here would be to change it to also walk VECTOR_CST components. So that= 's what I'm going to try first.=