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 EF841385381C for ; Thu, 13 Oct 2022 13:16:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EF841385381C 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=1665666999; h=from:from: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=lhd0CMmU6g6tlVyPpv2BkcrTxP/aWkE2YSkauI/z7L4=; b=bB7KxhS178VySq/IkmHiBI+OhWwx/WOL798kr5hNzl1B0TddRPgUU7DXPxNnI8DQ2nyDW1 acQrupDekEV9RbAG7c6gDKI3+qvWGFlPS8e1M7x6sx4Dx5t66RpsvXsNzQ8DkNSqqVVBBM /bxRxZnGSa1hQBLMQ0Bej7RQeEYvrfI= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-32-cifQixg5P1KUGG0pqUZVFQ-1; Thu, 13 Oct 2022 09:16:38 -0400 X-MC-Unique: cifQixg5P1KUGG0pqUZVFQ-1 Received: by mail-qt1-f198.google.com with SMTP id gc10-20020a05622a59ca00b003951e095c04so1125488qtb.4 for ; Thu, 13 Oct 2022 06:16:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=lhd0CMmU6g6tlVyPpv2BkcrTxP/aWkE2YSkauI/z7L4=; b=yHwy/9O1Q+M0+9/78H/Q2Bewijm/N9TRspo5h6X1YUCnrPBUMWvskJg6eiqxUZGqZy B/TxmXfGtTDBULMduDVIiNgA/pJNabkqzp/qIET0/pVjYQ/XloHDjusHkO8Dqr9us4HZ /uhQQppG+ppcc7WOw4YLz7H1h1ezg7LIcLoFz6XXgzst3doOuHmIzkfm8j31oCXwwKZx azfC4iiTcf6CttcVgusLwWpbjgNZ7htG0GaKBSv97SZrWPr04pQ81tl2HrEcTcy44Q0j 2NWgoBjHeOKSb3wmAHvvaIfujb20CTuPq+1ltpggYUpRI7q7uscazpam5EWFvH0Gmir1 2nHw== X-Gm-Message-State: ACrzQf3dVFhoUDyy88CF2hGgLyneIOniwHr1VSQ0Cqn1dNejZMbHBkEe SSLUSvwaOmJDhYqN85JyDQtKfZh/a1RnZ6iXRlo3cGGmKbqIPw80rToQZMBzw61yqsC9iLdUvIJ yqNQnlZu7aPK3OZYIig== X-Received: by 2002:a05:622a:182a:b0:35b:b0aa:f418 with SMTP id t42-20020a05622a182a00b0035bb0aaf418mr27715326qtc.379.1665666998127; Thu, 13 Oct 2022 06:16:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5FVWaOUDtXVimMRkZ4PiXMinFig7Y9RHcPlRWzGEYEOWQQpFyW/AOs105WKMTYPp/t0QdsNQ== X-Received: by 2002:a05:622a:182a:b0:35b:b0aa:f418 with SMTP id t42-20020a05622a182a00b0035bb0aaf418mr27715296qtc.379.1665666997825; Thu, 13 Oct 2022 06:16:37 -0700 (PDT) Received: from ?IPV6:2607:fea8:a263:f600::50d4? ([2607:fea8:a263:f600::50d4]) by smtp.gmail.com with ESMTPSA id q6-20020a05620a0d8600b006bb82221013sm18533186qkl.0.2022.10.13.06.16.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 13 Oct 2022 06:16:37 -0700 (PDT) Message-ID: <6eb14d77-79ef-dda3-b558-1c90883bacc5@redhat.com> Date: Thu, 13 Oct 2022 09:16:35 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.1 Subject: Re: [PATCH] middle-end IFN_ASSUME support [PR106654] To: Jakub Jelinek , Richard Biener Cc: Jan Hubicka , Aldy Hernandez , gcc-patches@gcc.gnu.org References: <244e087a-8680-9c21-0774-c7b6621e2eda@redhat.com> <144534bb-c25e-5303-47e5-cf56beb98261@redhat.com> <94879a41-16b5-6ec4-51ab-4d931b608147@redhat.com> From: Andrew MacLeod In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,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 10/13/22 05:53, Jakub Jelinek wrote: > 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. > I dont think we need to change anything.  All I intend to do is provide something that looks for the returns, wire GORI in, and reuse a global range table in to a reverse dependency walk to starting with a range of [1,1] for whatever is on the return stmt. From GORIs point of view, thats all outgoing_edge_range_p () does, except it picks up the initial value of [0,0] or [1,1]  from the specified edge instead. Initially It'll stop at the top of the block, but I don't think its too much work beyond that provide "simple" processing of PHIs and edges coming into the block..  In the absence of loops it should be pretty straightforward.  "All" you do is feed the value of the phi argument to the previous block.  Of course it'll probably be a little more complicated than that, but the basic premise seems pretty straightforward. The result produced would be vector over the ssa-names in the function with any ranges that were determined.   You could use that to more efficiently store just the values of the parameters somewhere and somehow associate them with the assume function decl. I'll try to get to this shortly. Andrew