From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 1F64B3858401 for ; Wed, 28 Jun 2023 10:21:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1F64B3858401 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 24C892188D; Wed, 28 Jun 2023 10:21:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1687947705; h=from:from:reply-to:date:date:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=ZBk8pnrwp+WQ3CTl0PKZIck/lpdyMMJBqD2BnF61KrY=; b=xCRaY8ngrT0CoXVo9zMxatOC+1oON2zylmC5kyqISFYCXr+LkAZYKb69SAUVHnPBAT24i0 KRDTZW3UukrT//+UVe+dyTy1kiUslIBYDVLax6woRru6lYwcs+zSfstzxw2qomCSaEuknN fLIDP63hta5QLzuVdp9nR53Lk/mVzJM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1687947705; h=from:from:reply-to:date:date:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=ZBk8pnrwp+WQ3CTl0PKZIck/lpdyMMJBqD2BnF61KrY=; b=9iIFaVmnOKF5X3u/HRUYNtsrL1EfITezll6c8YlMaZ+kS+jplPsy7Bl6Hb4Yta+ZJSO1+8 S2i/J3Mze20h9vBA== Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 177282C2E7; Wed, 28 Jun 2023 10:21:45 +0000 (UTC) Date: Wed, 28 Jun 2023 10:21:45 +0000 (UTC) From: Richard Biener To: gcc-patches@gcc.gnu.org cc: Jakub Jelinek Subject: [PATCH] tree-optimization/110434 - avoid ={v} {CLOBBER} from NRV User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,MISSING_MID,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Message-ID: <20230628102145.wWJngwyBb2P3RonZRAP6EIPYCscG7DjMS6ARvcUlWMA@z> When NRV replaces a local variable with it also replaces occurences in clobbers. This leads to being clobbered before the return of it which is strictly invalid but harmless in practice since there's no pass after NRV which would remove earlier stores. The following fixes this nevertheless. Bootstrapped and tested on x86_64-unknown-linux-gnu, OK? Thanks, Richard. PR tree-optimization/110434 * tree-nrv.cc (pass_nrv::execute): Remove CLOBBERs of VAR we replace with . --- gcc/tree-nrv.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gcc/tree-nrv.cc b/gcc/tree-nrv.cc index ff47439647c..466b491e4e7 100644 --- a/gcc/tree-nrv.cc +++ b/gcc/tree-nrv.cc @@ -256,6 +256,14 @@ pass_nrv::execute (function *fun) gsi_remove (&gsi, true); release_defs (stmt); } + /* If this is a CLOBBER of VAR, remove it. */ + else if (gimple_clobber_p (stmt) + && gimple_assign_lhs (stmt) == found) + { + unlink_stmt_vdef (stmt); + gsi_remove (&gsi, true); + release_defs (stmt); + } else { struct walk_stmt_info wi; -- 2.35.3