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.133.124]) by sourceware.org (Postfix) with ESMTPS id 8A8973850208 for ; Thu, 13 Oct 2022 09:53:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8A8973850208 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=1665654829; 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=SIjpXuarlRw003Tzpn8F7d3cCmh9JECZKQfMVOdLuis=; b=bt1iLLlGw0RJBf3kVmb9a9qwaXbsjlnAg134ie/bByGSrd24wsYRAsEJ4EUajCCYBpuxTR auVI8FynNOn1wwfKGWd/qKWHgBGZC3zFZmNI1hDg5VBVf/WIpSzCGVzwiXBVTceJ5XUUJd 6gS6jQI5Swss15fCv7fluN/b4qp6/N8= 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-616-KA9inPRTNh-O-vq-fEW4CA-1; Thu, 13 Oct 2022 05:53:45 -0400 X-MC-Unique: KA9inPRTNh-O-vq-fEW4CA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6CB1385A5B6; Thu, 13 Oct 2022 09:53:45 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.55]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 24944201156A; Thu, 13 Oct 2022 09:53:45 +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 29D9rgVt2964667 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 13 Oct 2022 11:53:42 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 29D9reOa2964666; Thu, 13 Oct 2022 11:53:40 +0200 Date: Thu, 13 Oct 2022 11:53:40 +0200 From: Jakub Jelinek To: Richard Biener Cc: Andrew MacLeod , Jan Hubicka , Aldy Hernandez , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] middle-end IFN_ASSUME support [PR106654] Message-ID: Reply-To: Jakub Jelinek References: <244e087a-8680-9c21-0774-c7b6621e2eda@redhat.com> <144534bb-c25e-5303-47e5-cf56beb98261@redhat.com> <94879a41-16b5-6ec4-51ab-4d931b608147@redhat.com> MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,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 Thu, Oct 13, 2022 at 08:11:53AM +0000, Richard Biener wrote: > On Wed, 12 Oct 2022, Andrew MacLeod wrote: > > > > > On 10/12/22 10:39, Jakub Jelinek wrote: > > > On Wed, Oct 12, 2022 at 10:31:00AM -0400, Andrew MacLeod wrote: > > >> I presume you are looking to get this working for this release, making the > > >> priority high? :-) > > > Yes. So that we can claim we actually support C++23 Portable Assumptions > > > and OpenMP assume directive's hold clauses for something non-trivial so > > > people won't be afraid to actually use it. > > > Of course, first the posted patch needs to be reviewed and only once it gets > > > in, the ranger/GORI part can follow. As the latter is only an optimization, > > > it can be done incrementally. > > > > I will start poking at something to find ranges for parameters from the return > > backwards. > > If the return were > > if (return_val) > return return_val; > > you could use path-ranger with the parameter SSA default defs as > "interesting". So you "only" need to somehow interpret the return > statement as such and do path rangers compute_ranges () If it was easier for handling, another possible representation of the assume_function could be not that it returns a bool where [1,1] returned means defined behavior, otherwise UB, but that the function returns void and the assumption is that it returns, the other paths would be __builtin_unreachable (). But still in both cases it needs a specialized backwards walk from the assumption that either it returns [1,1] or that it returns through GIMPLE_RETURN to be defined behavior. In either case, external exceptions, or infinite loops or other reasons why the function might not return normally (exit/abort/longjmp/non-local goto etc.) are still UB for assumptions. Say normally, if we have: extern void foo (int); bool assume1 (int x) { foo (x); if (x != 42) __builtin_unreachable (); return true; } we can't through backwards ranger walk determine that x_1(D) at the start of the function has [42,42] range, we can just say it is true at the end of the function, because foo could do if (x != 42) exit (0); or if (x != 42) throw 1; or if (x != 42) longjmp (buf, 1); or while (x != 42) ; or if (x != 42) abort (); But with assumption functions we actually can and stick [42, 42] on the parameters even when we know nothing about foo function. Of course, perhaps initially, we can choose to ignore those extra guarantees. Jakub