From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 447E5385843C; Mon, 4 Oct 2021 21:44:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 447E5385843C From: "qinzhao at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/102285] New flag -ftrivial-auto-var-init=zero causes crash in pr82421.c Date: Mon, 04 Oct 2021 21:44:26 +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: 12.0 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: qinzhao at gcc dot gnu.org X-Bugzilla-Status: REOPENED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: rguenth 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 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, 04 Oct 2021 21:44:27 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102285 --- Comment #28 from qinzhao at gcc dot gnu.org --- (In reply to Richard Biener from comment #21) > Reduced testcase: >=20 > int > qy (void) > { > int tw =3D 4; > int fb[tw]; > return fb[2]; > } For this reduced testing case, if compiled with=20 /home/opc/Install/latest/bin/gcc -c -O -ftrivial-auto-var-init=3Dzero -fdump-tree-all t.c ******t.c.032t.cpp1: int qy (int l9) { unsigned char fb.3[16]; int tw; int[0:D.1984] * fb.1; sizetype D.1984; void * saved_stack.2_16; int _27; : saved_stack.2_16 =3D __builtin_stack_save (); fb.1_25 =3D &fb.3; (*fb.1_25) =3D .DEFERRED_INIT (16, 2, 1); _27 =3D (*fb.1_25)[2]; .. } ******t.c.033t.forwprop1: int qy (int l9) { unsigned char fb.3[16]; int tw; int[0:D.1984] * fb.1; sizetype D.1984; void * saved_stack.2_16; int _27; : saved_stack.2_16 =3D __builtin_stack_save (); MEM[(int[0:D.1984] *)&fb.3] =3D .DEFERRED_INIT (16, 2, 1); _27 =3D MEM[(int[0:D.1984] *)&fb.3][2]; .. } the problem with the above IR for .DEFERRED_INIT expansion is: for MEM[(int[0:D.1984] *)&fb.3] =3D .DEFERRED_INIT (16, 2, 1); after the "ccp" and "forwprop", the original VLA *fb.1 is replaced with the= the new fixed array &fb.3, however, the VAR_TYPE still is the old VLA type int[0:D.1984]. if we can replace the var_type to the new "unsigned char [16= ]" for both the LHS and the call to .DEFERRED_INIT. then expansion through assign_expand should work. We might need to special handling the LHS to get the new type for "fb.3" instead of the old "var_type" for "assign_expand".=