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 752F03858D1E for ; Mon, 24 Apr 2023 12:32:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 752F03858D1E 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=1682339577; 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=/MRX8zbxiGu/7zjv+LyzyTzaVTjgEoYcQjSNSjfJd1Y=; b=dXePe4KAM0QaZRh/SBVRCBaa6Q3ENbl5dTG0ToxQe9VzIFJ7BctcpJLnSpN8WMkktMr5ua bOYCUBXR0DSCfUt6W3Y5hRYVCK9N9bU/MxNe5VvjY00+uBqCLWvPrvS4oqnHJu+7rX1F6i UADgRP/IzvRnPT0zIqyYDpaTzt5ZTbg= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-350-P2B-MF2aPkeBLuGpl2claA-1; Mon, 24 Apr 2023 08:32:55 -0400 X-MC-Unique: P2B-MF2aPkeBLuGpl2claA-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-3f17b8d24bbso27293425e9.2 for ; Mon, 24 Apr 2023 05:32:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682339574; x=1684931574; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/MRX8zbxiGu/7zjv+LyzyTzaVTjgEoYcQjSNSjfJd1Y=; b=jaZI6Zr6XP9t1rEJFDfD3oOgwXpXb8DQ4zs+JAeYmL7HHj/Wf2uJBwi/hG2CA57wf7 pD13BdUpPyYlc8SqAdTyOmHo5Vr1WeicY/6KQ8BefCcRUg8O7a/yMLBGoFWAiz7Gd3vK ghCeUF6HIKBUImrIa5VzBlPFD12UI88B7mR1DYlLqDJl8iZEIKSUQ2EK2ng2eZHBoiua PhHyBXcmdZ9C2p/iNm6BdyiIIwxbZqK5YdG0G7BkSLg1NVlyxrcz6Sw3DRhTNnYNM/Oh S8IW2/i0vtqBLmG8KpHn3IbhniETTNzzBMhOHUs44Pmi+KDbNaFALskYTx6/YsY58bXv 9p1w== X-Gm-Message-State: AAQBX9dQhJo/dLh4TS/jPQsdOcCP6jYW0CeRqHFz6zpY7L+825XrBa10 q0I0eNy9KFBgVFLX2aU4ncgSFnTBc9FYD7o3Lk8ttgV8PhLVZCCxz2laET6uordW76olDsgmfDA EkMewFh2h5aqR8MeklA== X-Received: by 2002:a05:600c:2194:b0:3f1:735b:9c4b with SMTP id e20-20020a05600c219400b003f1735b9c4bmr7570061wme.37.1682339574263; Mon, 24 Apr 2023 05:32:54 -0700 (PDT) X-Google-Smtp-Source: AKy350a4YHxAs7pguj+Bi0UlMvvwg9AN+r6TpRiEZJcLP080ldgRdJyYjOcqa8WwWPfuOhNvhbNOlw== X-Received: by 2002:a05:600c:2194:b0:3f1:735b:9c4b with SMTP id e20-20020a05600c219400b003f1735b9c4bmr7570047wme.37.1682339573948; Mon, 24 Apr 2023 05:32:53 -0700 (PDT) Received: from [192.168.1.201] ([139.47.42.170]) by smtp.gmail.com with ESMTPSA id y21-20020a05600c365500b003f182a10106sm12173876wmq.8.2023.04.24.05.32.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 24 Apr 2023 05:32:53 -0700 (PDT) Message-ID: Date: Mon, 24 Apr 2023 14:32:52 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH] Pass correct type to irange::contains_p() in ipa-cp.cc. To: Richard Biener Cc: GCC patches , Andrew MacLeod References: <20230424074332.141890-1-aldyh@redhat.com> <9db305b9-62fb-1b07-656a-13d029a7f730@redhat.com> From: Aldy Hernandez 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=-12.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,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 4/24/23 14:10, Richard Biener wrote: > On Mon, Apr 24, 2023 at 1:51 PM Aldy Hernandez wrote: >> >> >> >> On 4/24/23 10:30, Richard Biener wrote: >>> On Mon, Apr 24, 2023 at 9:44 AM 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 legacy >>>> 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, int 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 = 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? > It's not ranger that's unhappy, this is just irange::contains_p(). IPA works on both integers and pointers, and pointers don't have TYPE_MIN/MAX_VALUE defined, so we ICE in int_fits_type_p: type_low_bound = TYPE_MIN_VALUE (type); type_high_bound = TYPE_MAX_VALUE (type);