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 282753858D39 for ; Wed, 19 Oct 2022 16:07:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 282753858D39 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=1666195623; 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=H3pWVwuRtXPjBa7lY76BMlg9OVvMnQEatm0BGb9kaJA=; b=Wg9H6yA5HaiXPMkWCBKnD1S+JoBVny8Zak3QOqfzmBoDIJkqAYQStP+jk4AI5fFSxElUz3 66atxHVIqg/yOxdawPJ9En5AtM884nfLcoj1mcGl/PzKgQXnmv+vs42cXrKjQVUTzQLGCB LLnBw36S2W6z8evAggM1dYdLbr47ET0= 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-613-irxfFo89Pau8-asb_D7rIw-1; Wed, 19 Oct 2022 12:07:00 -0400 X-MC-Unique: irxfFo89Pau8-asb_D7rIw-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D6EB9811E81; Wed, 19 Oct 2022 16:06:59 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.193.252]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 88BE0492B05; Wed, 19 Oct 2022 16:06:58 +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 29JG6Tbh3962783 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 19 Oct 2022 18:06:35 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 29JG67Cs3962781; Wed, 19 Oct 2022 18:06:07 +0200 Date: Wed, 19 Oct 2022 18:06:07 +0200 From: Jakub Jelinek To: Andrew MacLeod Cc: Richard Biener , Jan Hubicka , gcc-patches@gcc.gnu.org, "hernandez, aldy" Subject: Re: [PATCH] middle-end, v4: IFN_ASSUME support [PR106654] Message-ID: Reply-To: Jakub Jelinek References: <479fa663-fb3e-a90d-ae7a-0fdd5acbfa00@redhat.com> <16da3b46-f061-076a-19b5-c482f45477b3@redhat.com> MIME-Version: 1.0 In-Reply-To: <16da3b46-f061-076a-19b5-c482f45477b3@redhat.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=WINDOWS-1252 Content-Disposition: inline Content-Transfer-Encoding: 8bit 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_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: Hi! On Tue, Oct 18, 2022 at 05:31:58PM -0400, Andrew MacLeod wrote: > Anyway, gives you something to experiement with.   If you would find a > different interface useful, let me know, or if there are limitations or > other expansions we might need.   This seems like something reasonable for > you to start working with? Thanks for working on this. > + // Look for ASSUME calls, and call query_assume_call for each argument > + // to determine if there is any inferred range to be had. > + if (is_a (s) && gimple_call_internal_p (s) > + && gimple_call_internal_fn (s) == IFN_ASSUME) > + { > + tree assume_id = gimple_call_arg (s, 0); > + for (unsigned i = 1; i < gimple_call_num_args (s); i++) > + { > + tree op = gimple_call_arg (s, i); > + tree type = TREE_TYPE (op); > + if (gimple_range_ssa_p (op) && Value_Range::supports_type_p (type)) > + { > + Value_Range assume_range (type); > + if (query_assume_call (assume_range, assume_id, op)) > + { > + add_range (op, assume_range); > + if (dump_file) > + { > + print_generic_expr (dump_file, assume_id, TDF_SLIM); > + fprintf (dump_file, " assume inferred range of "); > + print_generic_expr (dump_file, op, TDF_SLIM); > + fprintf (dump_file, " to "); > + assume_range.dump (dump_file); > + fputc ('\n', dump_file); > + } > + } Not sure I understand this part. op is whatever we pass as the ith argument to IFN_ASSUME. I'd expect that at this point one needs to remap that to the (i-1)th PARM_DECL of assume_id (so e.g. when you have the above loop you could as well start with DECL_ARGUMENTS and move that to DECL_CHAIN at the end of every iteration. And then query ssa_default_def (DECL_STRUCT_FUNCTION (assume_id), parm) in each case and get global range of what that returns. > + for (unsigned x= 0; x < gimple_phi_num_args (phi); x++) for (unsigned x = 0; ... ? > @@ -4345,6 +4345,30 @@ execute_ranger_vrp (struct function *fun, bool warn_array_bounds_p) > scev_initialize (); > calculate_dominance_info (CDI_DOMINATORS); > > + assume_query *r2 = new assume_query (); > + for (unsigned i = 0; i < num_ssa_names; i++) > + { > + tree name = ssa_name (i); > + if (!name || !gimple_range_ssa_p (name)) > + continue; > + tree type = TREE_TYPE (name); > + if (!Value_Range::supports_type_p (type)) > + continue; > + Value_Range assume_range (type); > + if (r2->assume_range_p (assume_range, name)) > + { > + if (dump_file) > + { > + fprintf (dump_file, "for an assume function, "); > + print_generic_expr (dump_file, name, TDF_SLIM); > + fprintf (dump_file, " would have a range of "); > + assume_range.dump (dump_file); > + fputc ('\n', dump_file); > + } > + } > + } > + delete r2; I have expected (but tell me if that isn't possible) this could be something done in the new pass_assumptions::execute () rather than vrp and you'd create the assume_query there (i.e. just for assume_functions) and then query it solely for ssa_default_def of the parameters and save in SSA_NAME_RANGE_INFO. But my knowledge about ranger is fairly limited... Jakub