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 110903857C44 for ; Thu, 6 Apr 2023 10:38:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 110903857C44 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=1680777511; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wDZmFDoJv3/f7yVd4G2mLbEBslN4uSwVMFc5ZgftGLA=; b=Q0tlA3LJE3v8jC4P6qm/hwcXwbopneZYLU3RwiTQm4qzipbYo0ad4iz04gVdb4SAeVzGHM cWBRDQaKU/Faxg98DOL9DKa3JhxaHMmADgCz2LkvklgmwXwq8Vpb95GSWzyBsIKN+HnK4F dO5KrQ0VBZwatMeKU8yEvun9W0iCbWY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-573-HyZN72MmNO-5uQohoqAFBQ-1; Thu, 06 Apr 2023 06:38:30 -0400 X-MC-Unique: HyZN72MmNO-5uQohoqAFBQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B9EDE185A78B; Thu, 6 Apr 2023 10:38:29 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 51BB1C12901; Thu, 6 Apr 2023 10:38:29 +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 336AcQOi3994404 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 6 Apr 2023 12:38:27 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 336AcPf03994401; Thu, 6 Apr 2023 12:38:25 +0200 Date: Thu, 6 Apr 2023 12:38:25 +0200 From: Jakub Jelinek To: Andrew MacLeod , Richard Biener Cc: gcc-patches Subject: Re: [PATCH] PR tree-optimization/109417 - Check if dependency is valid before using in may_recompute_p. Message-ID: Reply-To: Jakub Jelinek References: MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.3 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_H2,SPF_HELO_NONE,SPF_NONE,TXREP 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, Apr 05, 2023 at 04:10:25PM -0400, Andrew MacLeod via Gcc-patches wrote: > When a statement is first processed, any SSA_NAMEs that are dependencies are > cached for quick future access. > > if we ;later rewrite the statement (say propagate a constant into it), its > possible the ssa-name in this cache is no longer active.   Normally this is > not a problem, but the changed to may_recompute_p forgot to take that into > account, and was checking a dependency from the cache that was in the > SSA_NAME_FREE_LIST. It thus had no SSA_NAME_DEF_STMT when we were expecting > one. > > This patch simply rejects dependencies from consideration if they are in the > free list. > > Bootstrapping on x86_64-pc-linux-gnu  and presuming no regressio0ns, OK for > trunk? > > Andrew > commit ecd86e159e8499feb387bc4d99bd37a5fd6a0d68 > Author: Andrew MacLeod > Date: Wed Apr 5 15:59:38 2023 -0400 > > Check if dependency is valid before using in may_recompute_p. > > When the IL is rewritten after a statement has been processed and > dependencies cached, its possible that an ssa-name in the dependency > cache is no longer in the IL. Check this before trying to recompute. > > PR tree-optimization/109417 > gcc/ > * gimple-range-gori.cc (gori_compute::may_recompute_p): Check if > dependency is in SSA_NAME_FREE_LIST. > > gcc/testsuite/ > * gcc.dg/pr109417.c: New. Ok for trunk (mainly to unbreak the recent regression). But please be ready to adjust if Richi disagrees next week. > --- a/gcc/gimple-range-gori.cc > +++ b/gcc/gimple-range-gori.cc > @@ -1314,7 +1314,9 @@ gori_compute::may_recompute_p (tree name, basic_block bb, int depth) > tree dep2 = depend2 (name); > > // If the first dependency is not set, there is no recomputation. > - if (!dep1) > + // Dependencies reflect original IL, not current state. Check if the > + // SSA_NAME is still valid as well. > + if (!dep1 || SSA_NAME_IN_FREE_LIST (dep1)) > return false; > > // Don't recalculate PHIs or statements with side_effects. Jakub