From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 029243858D35 for ; Wed, 28 Jun 2023 10:37:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 029243858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687948666; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=cwEf9+NijB402rccgzLaKRYJGdR+fM8OLf83Kk4toPw=; b=Mj/22qr4TGCBWLcc1bfb4pIAOqzDJVPL8aIpvJo2y00UKAcuHtePbPG6cmcWBxKQUIEmD7 1xE4hSWCutzq5AAxVIro6/2Xo9fETbJhG/fpeSGUJS+VkeUB0YBzxB0Ud3oFKL412mNVUd 86PDD6+HCZSIlJNhmb0OQa0XoorEJqE= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-277-oRrclta1OTCeh8OKbOl1Zw-1; Wed, 28 Jun 2023 06:37:45 -0400 X-MC-Unique: oRrclta1OTCeh8OKbOl1Zw-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DC692296A604; Wed, 28 Jun 2023 10:37:44 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.195.172]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9EAC7492B02; Wed, 28 Jun 2023 10:37:44 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 35SAbfbQ010222 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 12:37:42 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 35SAbfuO010221; Wed, 28 Jun 2023 12:37:41 +0200 Date: Wed, 28 Jun 2023 12:37:40 +0200 From: Jakub Jelinek To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] tree-optimization/110434 - avoid ={v} {CLOBBER} from NRV Message-ID: Reply-To: Jakub Jelinek References: <20230628102150.620743857B8E@sourceware.org> MIME-Version: 1.0 In-Reply-To: <20230628102150.620743857B8E@sourceware.org> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,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: On Wed, Jun 28, 2023 at 10:21:45AM +0000, Richard Biener via Gcc-patches wrote: > 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 . This is in a loop over all basic blocks in a function. Do we want to kill all clobbers, or just the ones at the end of functions (i.e. after the = VAR; assignment that we also remove)? Complication is that doesn't necessarily have to be just the rest of a single basic block, but all basic blocks from that point until end of function. I mean, if we have var = whatever; use (var); var = {CLOBBER}; ... var = whatever_else; = var; var = {CLOBBER}; killing the first clobber might result in missed optimizations later on. On the other side, could there be partial clobbers for the var -> , var.fld = {CLOBBER}; ? Or even worse, indirect clobbers (MEM_REF with SSA_NAME pointing to var or parts of it)? Jakub