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 D19753858C56 for ; Tue, 7 May 2024 10:22:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D19753858C56 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D19753858C56 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715077359; cv=none; b=qnXZIHOZXNgpsW3cd8aRdyBzDvnctgU8v5t7Nfeo5DQCuX7EDhSq7nGW76DYo7jgFlxoPORjTPoAFX83NJ5w20MY6s6b0Uf9E/76OenkWQo1rgww93l0Q/qn91oPPJAgJImqvxaIp6HEjTIPg+vP+VwuqXEKRml8AHrJZzs/42c= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715077359; c=relaxed/simple; bh=3MRZ4lfK34Kx3aCZW9xclJ5Otr2RsxrH2A6xOsNBD0A=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=Qeze2HFvf0TfMck1e7UV2xIM9IH3R23OuYnkCGefUBxrYf+OpGGSCoatH/s/9DyV0HhDf+UdBG6HcjIiC5PTNYzmIQQ4BoJnTJ21/UiX4Zevm0NdlGWSWSQ7HzTd4i/4xE2vKkZZ4jb8t3w0zs8ZQ3zjooryMwKVd9fZ3nYutTQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1715077357; 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=EkPFcht5mC0MWr807xOjQ96eEmgiaqu7w3dYiPcQU5U=; b=A5hmHsRvs9CBD6JJdlTZMNaIzfJirHRSgP/X8XdRML+04brRBvAMLaqQcWjR2CsM7+OvU/ k5pSqd8dIpC6dUcIaYdLgQHI/S0oJ2144CweE2TCK3jwCLelLrPqVJc0Q5Z3+PJtA5x75Z 24XFQRkQwYvJZKUALMY0L2cFEwhiQz0= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-549-bStqOXevOzW6llvVCm564Q-1; Tue, 07 May 2024 06:22:36 -0400 X-MC-Unique: bStqOXevOzW6llvVCm564Q-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a58ede3d114so96747366b.3 for ; Tue, 07 May 2024 03:22:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715077354; x=1715682154; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EkPFcht5mC0MWr807xOjQ96eEmgiaqu7w3dYiPcQU5U=; b=ticIF3eqVwzkn5Yy+s50oafVv5Ky25XtiZ4im4/hJaxpkCsgkJUazL/iug0ux5SHkF 00gW18MWvUcCntMHtE9oPHWPZ5gtEuAIso1vw7NCNw95HayN3iAFd7EJSMV9HgF3wJHX HUJHp4nJxtJdDAxuPTFyqUrp1y4nwkaCpbuxu+rPuCwH+gAYHJewMsEXB2EiRgMg08ck Vii7zKWH48MM5g/VepoYOrum3Hz/smuLZ3+f15HXwjtm+wkSq8a054ei+0JWFZ9Hw5fO vIm+VAXOlETQ9Q12yZfU2tx8jPzv8AyEmMJTjJG5wUjrl6V2I2f08TZtCUJyPXQelleI jVXA== X-Gm-Message-State: AOJu0Yx3rlMXyiOHUubFSipPpLcq0xYC1xoLP/bj+wVx2IyQ411N8Z7H 3ZEbE5hIsgzhLOE9KwO9EaZxiBofUHbgJGiZ0rxdqqPcBlDA7cXqQi5RW28nESiQPRCpRDvNcbp aPo6PgLFcBd5srz58KTmbSn3Zfh3fxDmcFYOAyIhHZp3k3Dq4MaRApXhgpTVZi3pKSZoVCVTA9I gSpfwd752q7Ga+vZcSg1V2dZKLTCycq16kcVBq2w== X-Received: by 2002:a50:ccd3:0:b0:570:5bcc:f749 with SMTP id b19-20020a50ccd3000000b005705bccf749mr11192886edj.29.1715077354685; Tue, 07 May 2024 03:22:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGYcY8c176w827/RI/74bfglETEqXaxcBBUSPJlPtuh0VxzCqGbxJ4bhdCrM+tcMHB4DjHMPMYzVcjHLGuoZvM= X-Received: by 2002:a50:ccd3:0:b0:570:5bcc:f749 with SMTP id b19-20020a50ccd3000000b005705bccf749mr11192874edj.29.1715077354321; Tue, 07 May 2024 03:22:34 -0700 (PDT) MIME-Version: 1.0 References: <20240428200959.1249849-1-aldyh@redhat.com> In-Reply-To: <20240428200959.1249849-1-aldyh@redhat.com> From: Aldy Hernandez Date: Tue, 7 May 2024 12:22:23 +0200 Message-ID: Subject: Re: [PATCH] Minor range type fixes for IPA in preparation for prange. To: GCC patches Cc: Martin Jambor , Andrew MacLeod X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,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: Pushed to trunk. On Sun, Apr 28, 2024 at 10:10=E2=80=AFPM Aldy Hernandez = wrote: > > The polymorphic Value_Range object takes a tree type at construction > so it can determine what type of range to use (currently irange or > frange). It seems a few of the types are slightly off. This isn't a > problem now, because IPA only cares about integers and pointers, which > can both live in an irange. However, with prange coming about, we > need to get the type right, because you can't store an integer in a > pointer range or vice versa. > > Also, in preparation for prange, the irange::supports_p() idiom will beco= me: > > irange::supports_p () || prange::supports_p() > > To avoid changing all these palces, I've added an inline function we > can later change and change everything at once. > > Finally, there's a Value_Range::supports_type_p() && > irange::supports_p() in the code. The latter is a subset of the > former, so there's no need to check both. > > OK for trunk? > > gcc/ChangeLog: > > * ipa-cp.cc (ipa_vr_operation_and_type_effects): Use ipa_supports= _p. > (ipa_value_range_from_jfunc): Change Value_Range type. > (propagate_vr_across_jump_function): Same. > * ipa-cp.h (ipa_supports_p): New. > * ipa-fnsummary.cc (evaluate_conditions_for_known_args): Change V= alue_Range type. > * ipa-prop.cc (ipa_compute_jump_functions_for_edge): Use ipa_supp= orts_p. > (ipcp_get_parm_bits): Same. > --- > gcc/ipa-cp.cc | 14 +++++++------- > gcc/ipa-cp.h | 8 ++++++++ > gcc/ipa-fnsummary.cc | 2 +- > gcc/ipa-prop.cc | 8 +++----- > 4 files changed, 19 insertions(+), 13 deletions(-) > > diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc > index a688dced5c9..5781f50c854 100644 > --- a/gcc/ipa-cp.cc > +++ b/gcc/ipa-cp.cc > @@ -1649,7 +1649,7 @@ ipa_vr_operation_and_type_effects (vrange &dst_vr, > enum tree_code operation, > tree dst_type, tree src_type) > { > - if (!irange::supports_p (dst_type) || !irange::supports_p (src_type)) > + if (!ipa_supports_p (dst_type) || !ipa_supports_p (src_type)) > return false; > > range_op_handler handler (operation); > @@ -1720,7 +1720,7 @@ ipa_value_range_from_jfunc (vrange &vr, > > if (TREE_CODE_CLASS (operation) =3D=3D tcc_unary) > { > - Value_Range res (vr_type); > + Value_Range res (parm_type); > > if (ipa_vr_operation_and_type_effects (res, > srcvr, > @@ -1733,7 +1733,7 @@ ipa_value_range_from_jfunc (vrange &vr, > Value_Range op_res (vr_type); > Value_Range res (vr_type); > tree op =3D ipa_get_jf_pass_through_operand (jfunc); > - Value_Range op_vr (vr_type); > + Value_Range op_vr (TREE_TYPE (op)); > range_op_handler handler (operation); > > ipa_range_set_and_normalize (op_vr, op); > @@ -2527,7 +2527,7 @@ propagate_vr_across_jump_function (cgraph_edge *cs,= ipa_jump_func *jfunc, > if (src_lats->m_value_range.bottom_p ()) > return dest_lat->set_to_bottom (); > > - Value_Range vr (operand_type); > + Value_Range vr (param_type); > if (TREE_CODE_CLASS (operation) =3D=3D tcc_unary) > ipa_vr_operation_and_type_effects (vr, > src_lats->m_value_range.m_vr, > @@ -2540,16 +2540,16 @@ propagate_vr_across_jump_function (cgraph_edge *c= s, ipa_jump_func *jfunc, > { > tree op =3D ipa_get_jf_pass_through_operand (jfunc); > Value_Range op_vr (TREE_TYPE (op)); > - Value_Range op_res (operand_type); > + Value_Range op_res (param_type); > range_op_handler handler (operation); > > ipa_range_set_and_normalize (op_vr, op); > > if (!handler > - || !op_res.supports_type_p (operand_type) > + || !ipa_supports_p (operand_type) > || !handler.fold_range (op_res, operand_type, > src_lats->m_value_range.m_vr, op_vr= )) > - op_res.set_varying (operand_type); > + op_res.set_varying (param_type); > > ipa_vr_operation_and_type_effects (vr, > op_res, > diff --git a/gcc/ipa-cp.h b/gcc/ipa-cp.h > index 7ff74fb5c98..abeaaa4053e 100644 > --- a/gcc/ipa-cp.h > +++ b/gcc/ipa-cp.h > @@ -291,4 +291,12 @@ public: > > bool values_equal_for_ipcp_p (tree x, tree y); > > +/* Return TRUE if IPA supports ranges of TYPE. */ > + > +static inline bool > +ipa_supports_p (tree type) > +{ > + return irange::supports_p (type); > +} > + > #endif /* IPA_CP_H */ > diff --git a/gcc/ipa-fnsummary.cc b/gcc/ipa-fnsummary.cc > index dff40cd8aa5..1dbf5278149 100644 > --- a/gcc/ipa-fnsummary.cc > +++ b/gcc/ipa-fnsummary.cc > @@ -515,7 +515,7 @@ evaluate_conditions_for_known_args (struct cgraph_nod= e *node, > } > else if (!op->val[1]) > { > - Value_Range op0 (op->type); > + Value_Range op0 (TREE_TYPE (op->val[0])); > range_op_handler handler (op->code); > > ipa_range_set_and_normalize (op0, op->val[0]); > diff --git a/gcc/ipa-prop.cc b/gcc/ipa-prop.cc > index b57f9750431..2d5c51298f2 100644 > --- a/gcc/ipa-prop.cc > +++ b/gcc/ipa-prop.cc > @@ -2392,10 +2392,8 @@ ipa_compute_jump_functions_for_edge (struct ipa_fu= nc_body_info *fbi, > else > { > if (param_type > - && Value_Range::supports_type_p (TREE_TYPE (arg)) > - && Value_Range::supports_type_p (param_type) > - && irange::supports_p (TREE_TYPE (arg)) > - && irange::supports_p (param_type) > + && ipa_supports_p (TREE_TYPE (arg)) > + && ipa_supports_p (param_type) > && get_range_query (cfun)->range_of_expr (vr, arg, cs->call= _stmt) > && !vr.undefined_p ()) > { > @@ -5763,7 +5761,7 @@ ipcp_get_parm_bits (tree parm, tree *value, widest_= int *mask) > ipcp_transformation *ts =3D ipcp_get_transformation_summary (cnode); > if (!ts > || vec_safe_length (ts->m_vr) =3D=3D 0 > - || !irange::supports_p (TREE_TYPE (parm))) > + || !ipa_supports_p (TREE_TYPE (parm))) > return false; > > int i =3D ts->get_param_index (current_function_decl, parm); > -- > 2.44.0 >