From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id CC59A3857805; Tue, 25 Aug 2020 09:21:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CC59A3857805 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1598347268; bh=1RbZU1VlX9Qr9se8EfC0FKlUnli5JFdMKd1gFA3bsM0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=em+f90tb6UxIFwUIKgTZP/XoJl9YZUFAQ9qtNPjeeWmrRXOFDv4mz86X8juDttjuD tsz1dFwqob7o7O+3AZnVaMEcDzYT0h67Na93m/DF2Mfvzi3calQ2V5XANbektQbUTJ S8RTO5qv5FbcqBdug16XPTNy56eGpl3aFhVyXy3M= From: "glisse at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/96565] Failure to optimize out VLA even though it is left unused Date: Tue, 25 Aug 2020 09:21:08 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: glisse 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 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: Tue, 25 Aug 2020 09:21:08 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96565 --- Comment #4 from Marc Glisse --- (In reply to Richard Biener from comment #3) > I guess the "usual" way of dealing with this would be to have > CLOBBERs for all VLAs before the __builtin_stack_restore. That looks like a good idea. I didn't try to follow in a debugger why DSE fails to remove the write when those 2 builtins are present while it manages if I call __builtin_alloca_with_align directly, but I don't immediately see a reason = for that difference, even in the absence of clobbers. Or maybe that's just the usual limitations of DSE (there is a branch after all...). I first thought that __builtin_stack_save/restore might need some extra attributes (advertising for instance that they do not read/write memory or = let anything escape, without weakening them to the point where the compiler wou= ld move them around too much or remove them), but since the call to the opaque= g does not seem to prevent DSE from removing the write, that's probably not t= he issue.=