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 031D13858D35 for ; Sun, 5 May 2024 16:26:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 031D13858D35 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 031D13858D35 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=1714926366; cv=none; b=KrjS3EVNFf5Gz+dkiZOIt+IxPdcYOkJAVkR+PADlV2Ow7lLXb8wburkabzgdUpV5IJEivA+QURNb5xSVD/4DF5YA4w5AjjbpDf/9Pmpf7zuAWbHIaO+efmbZFAkDyFkSOcpN0rW6+PiR8rhl2Uy+binWnuwGy0YPHnFIZc51Uxs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714926366; c=relaxed/simple; bh=1H1h6ZQbJ+niKGwqdUFQfxzYSbp9gyar4SrvXee9efk=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=YXR1Mn1kM9WqZ8MAK4XDBVDLbWOTmI22nx6fMaotUKvqkvtIOiUpQ2I8MBYXrWa3g0zqHJmGVNpk/Bz+4uXiqxbRKKnKL3vLDwWrqbujD/AEp4xi4H9OdPTmRUeb6u7uCLITsIAeEnMjwXDHwVgOvpxA2U06Bxqha6NNfaAvov8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714926362; 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=kCMuSKNAiNNO8fv4nQXQvLOjd4JeO7bgpjAIgHVY+cw=; b=SPU4kZoVpBVAefSXjeNxnVh2HeOyg80dNTOpAnFKm0icghNcd45HDHhU4ervRMbbtChVn0 azWbQB1Y3kVcDLGB72obwxCHgGh+TH0AIHJNJBMeoYv7Mm+VoT14hHWXY0OXGZN5P6EK/J FC08bGd8KiIWKQc9GtkIEnqc4lD+Jxk= Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com [209.85.167.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-631-TeFyWOMjMzSfPQ65alKDHA-1; Sun, 05 May 2024 12:26:01 -0400 X-MC-Unique: TeFyWOMjMzSfPQ65alKDHA-1 Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-51f8aadbf04so1273389e87.0 for ; Sun, 05 May 2024 09:26:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714926359; x=1715531159; 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=kCMuSKNAiNNO8fv4nQXQvLOjd4JeO7bgpjAIgHVY+cw=; b=lJWBtSsJkj/ena5R6yHGx7wohq8DfnvZSvdUQJdmJEKs/WtO1Fvxw9L/aEqqWzQnI3 wKlEWiaApn/jGgyyoM9F2mQGE9LRCTUmXZGk3TazU91U3K8qYn/M424DzJ6RzHPY+V9G hw8DJ18wJV1TjSlkfFk4aCP+T3iBBw/AE5lkF1y7WcvJm3y+/d4VUYtcy03TPkV478TV hMtv7mCG+HEC9AJXg2iJRxe885EEANVqwIp+PCq6cBfmZHzRzlxC/5MxKXTJ1tx+DrzX NmC+77+5sd1LzQTMQzo2SJY9vDAPPAIOyDZa0VQYC5g8EgGy8DY8fXgQADk91hC20U+1 llQA== X-Gm-Message-State: AOJu0YzJLzCeNAyTcC6fmcdGVjXLcbkxGGbk2bwxYlDvmjEIDuhw6Pgv FNKDVg7SaqM6JlpLorJjt74vkf2aAhiTL6f22X1YgQlfvdRxb+lqOFSTVsQdZUPeODGCh2FXwD2 dddGztIzRAzQDCOwBdzKeHkVtzz0/zWIBo6zVnKpWuFiK5tan99Nbg3KZilAyw37Z4SxER3EUEk qdvvCFazRgQvp8X7E4XlK3afofJ5pUxkLUQNDH1g== X-Received: by 2002:ac2:5443:0:b0:51f:ca0b:fa0a with SMTP id d3-20020ac25443000000b0051fca0bfa0amr3406191lfn.35.1714926359363; Sun, 05 May 2024 09:25:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEPR7+xTM1h61DaPzOdC4qtEyvzKPMnLq4HEgCsFnFo1CBHh3S3jAblAw9AowgmKyJ6kXcTHkLY4HhyzIdrwsY= X-Received: by 2002:ac2:5443:0:b0:51f:ca0b:fa0a with SMTP id d3-20020ac25443000000b0051fca0bfa0amr3406181lfn.35.1714926358827; Sun, 05 May 2024 09:25:58 -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: Sun, 5 May 2024 18:25:47 +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=-11.7 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: PING. I can probably commit this patchlet as a ranger maintainer, but I'd prefer a nod from a global or IPA maintainer. It is the one patch that's needed before I can throw the switch on prange support later this week. Thanks. Aldy 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 >