From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by sourceware.org (Postfix) with ESMTPS id AB5473858D28 for ; Mon, 24 Apr 2023 12:12:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AB5473858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2a8a5f6771fso41508041fa.3 for ; Mon, 24 Apr 2023 05:12:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682338343; x=1684930343; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=8SeLGS6Xlr1xHVw80l2Wx1GLTGpTgiXu6UfoLBAw2NY=; b=FgvyRg48XrvSIdM/j+l6YemvkaxKcISzrHq7fPbBa997E07sLWJdVqRIhrna3A6yW8 lg6kezdWXesbPbVKFC8HM3HEbDKYdk/jlVXOB5EfkMLSEcXTtDydzUWhKgqxxTryLYbz VbezuDYRca6b/RIUadAba/cxMU/+9Khrqc8nf2mWkBQEW8ZLyGiEGzRV70gt+fRTy0eO cq+orbwWhjAQLlfas6g9ApQkqcACEN62bRRb7/FC80GaMw6jfGXFaWRIbspWfb80X68P TPD7HLRXMuGJZYmQILoGtP+F72q5gULk9T7YHJmBJoZjnam0nZppu5BQENhFgjM0YWlA qqsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682338343; x=1684930343; 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=8SeLGS6Xlr1xHVw80l2Wx1GLTGpTgiXu6UfoLBAw2NY=; b=PiopZkm/iI0Yf4P4qEFyzpgi4mBOrK1nVImhktByBwQmssXD4p1qqnBLqPhV9edWlq 4JsuCrW9eJVpA5d8rzgrJaE6jcj/xp9yP1CTNTzowq1eboSDqj3cS94DMEwvALQiz3/H quBgtgi1dICd27Yz60nWMQF6+He1yxRSGmTVTYLfJ/0baQDcvSlxGF3V7WNhzhU313Y/ Z76Db+D+BQQ0TfBeRJBpoSPofDM4d+ZjRu+Ub11ZRXYkAU5UO/2KY+0N6ETzWMua038V 9S41OikCdlV0myPy749YwJpsjiUImY4XKkdtE3l6R0MtjrjC2CrodZWcMlr3DFo5RyYK 0N2w== X-Gm-Message-State: AAQBX9c5VTKZhLLpPSxxpZMox2NW4lXkckWH+cUfRqY7BcR6bIP8b7D6 TStX2AqeJfB0SoJEmr3tPTVGobXWWajxibRMMhA= X-Google-Smtp-Source: AKy350ZKx2QvmleWvMB4Nsl6gHcqn0mnpzTXRNklLuUVmDakLeEhcb1VoM5NoYKIWHWg+R/hGpm7h4gIJKcbn+q3RNw= X-Received: by 2002:a2e:9ccd:0:b0:2a8:c377:831b with SMTP id g13-20020a2e9ccd000000b002a8c377831bmr2675734ljj.20.1682338343183; Mon, 24 Apr 2023 05:12:23 -0700 (PDT) MIME-Version: 1.0 References: <20230424074332.141890-1-aldyh@redhat.com> <9db305b9-62fb-1b07-656a-13d029a7f730@redhat.com> In-Reply-To: <9db305b9-62fb-1b07-656a-13d029a7f730@redhat.com> From: Richard Biener Date: Mon, 24 Apr 2023 14:10:57 +0200 Message-ID: Subject: Re: [PATCH] Pass correct type to irange::contains_p() in ipa-cp.cc. To: Aldy Hernandez Cc: GCC patches , Andrew MacLeod Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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 Mon, Apr 24, 2023 at 1:51=E2=80=AFPM Aldy Hernandez w= rote: > > > > On 4/24/23 10:30, Richard Biener wrote: > > On Mon, Apr 24, 2023 at 9:44=E2=80=AFAM Aldy Hernandez via Gcc-patches > > wrote: > >> > >> There is a call to contains_p() in ipa-cp.cc which passes incompatible > >> types. This currently works because deep in the call chain, the legac= y > >> code uses tree_int_cst_lt which performs the operation with > >> widest_int. With the upcoming removal of legacy, contains_p() will be > >> stricter. > >> > >> OK pending tests? > >> > >> gcc/ChangeLog: > >> > >> * ipa-cp.cc (ipa_range_contains_p): New. > >> (decide_whether_version_node): Use it. > >> --- > >> gcc/ipa-cp.cc | 16 +++++++++++++++- > >> 1 file changed, 15 insertions(+), 1 deletion(-) > >> > >> diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc > >> index b3e0f62e400..c8013563796 100644 > >> --- a/gcc/ipa-cp.cc > >> +++ b/gcc/ipa-cp.cc > >> @@ -6180,6 +6180,19 @@ decide_about_value (struct cgraph_node *node, i= nt index, HOST_WIDE_INT offset, > >> return true; > >> } > >> > >> +/* Like irange::contains_p(), but convert VAL to the range of R if > >> + necessary. */ > >> + > >> +static inline bool > >> +ipa_range_contains_p (const irange &r, tree val) > >> +{ > >> + if (r.undefined_p ()) > >> + return false; > >> + > >> + val =3D fold_convert (r.type (), val); > > > > I think that's wrong, it might truncate 'val'. I think we'd want > > > > if (r.undefined_p () || !int_fits_type_p (val, r.type ())) > > return false; > > This won't work for pointers. Is there a suitable version that handles > pointers as well? Where does it not work? And when do you get pointer values/types where they mismatch sufficiently (how?) to make ranger unhappy? > > > > but then I wonder whether contains_p should have an overload > > with widest_int or handle "out of bounds" values itself more gracefully= ? > > Only IPA is currently passing incompatible types to contains_p(), so I'd > prefer to keep things stricter until there is an actual need for them. > > Thanks. > Aldy >