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 C21FC3858D28 for ; Mon, 24 Apr 2023 11:51:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C21FC3858D28 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=1682337080; 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=sZ5DEQF07nmbV71+Ah22cSnIt53ThZP0TnMlc9AydhA=; b=V1cyID0AwFZFZsjzXvBmJ1rCVnGFARhUS1upDF76jLMO1PhMo6oH4wEfE9EBNoj47FjnjR qVSo8IgxFkUUMvCPqdTO0t3d7q95zMX4hRNgFCiyVuZ20IhhrCxW38T6XfDAvpVASkbkTG Wn+JzgCxJaYpdzLtIAoS9rX3AgTbjB0= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-620-olVWgUblNgSuznBynbUtwQ-1; Mon, 24 Apr 2023 07:51:19 -0400 X-MC-Unique: olVWgUblNgSuznBynbUtwQ-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-3f18b63229bso31779595e9.0 for ; Mon, 24 Apr 2023 04:51:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682337077; x=1684929077; 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=sZ5DEQF07nmbV71+Ah22cSnIt53ThZP0TnMlc9AydhA=; b=k7RhBEzSgfqfNHMTMSV7IiFQcWCiY225Ib3Ey9VvPPrlgXQB2r3xrFo5Azac+1lJpS 6QOfPRW9WFexKXnR8akIAnoZmvSab+7cTgGj5Xc04JcgNn+NcbX0AeAziDNsAhd8jq8p fOSAuLLCxUrCEGXWMyHe4c3YX2ig2raFmVs4G+i2IpcWDKp5CgObDoAHzd5FWlJNZ0uM eFW25JywcoIVwmB4pcTIuNmBKw+NWvuRv7jitQiI97WmQav493PhjQNXSxnrYPm7CVlb YUeU3Beagl/plAldLX1/mS2JumTPN4MyjjMhroNXs5YQA3qOS2FTf9Gxvd6YJeTBqsUO LaTg== X-Gm-Message-State: AAQBX9eISLxJoNLTp6lKRNJmX/kj0TJKD9bP+a35ZVj0z5aX+RA6MXoU cT9sNay01XPHh1G/w4s2cpu6HRWkqJ/eueG0kAmdMS5DJVMx5HeM91vDUEnwTlTCgqnX6b45BtL i1fnbez/o3i+QRB8bCQ== X-Received: by 2002:a7b:cc15:0:b0:3f1:65cb:8156 with SMTP id f21-20020a7bcc15000000b003f165cb8156mr7940353wmh.0.1682337077701; Mon, 24 Apr 2023 04:51:17 -0700 (PDT) X-Google-Smtp-Source: AKy350Zp61Lha66LJB7uGyd5VhpZsUZBQ5D6aICWkqHtBHeXUmxIFSVSDAc/1vMZieAWdoFUUSlsjg== X-Received: by 2002:a7b:cc15:0:b0:3f1:65cb:8156 with SMTP id f21-20020a7bcc15000000b003f165cb8156mr7940342wmh.0.1682337077353; Mon, 24 Apr 2023 04:51:17 -0700 (PDT) Received: from [192.168.1.201] ([139.47.42.170]) by smtp.gmail.com with ESMTPSA id s8-20020a05600c45c800b003f18992079dsm12475869wmo.42.2023.04.24.04.51.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 24 Apr 2023 04:51:16 -0700 (PDT) Message-ID: <9db305b9-62fb-1b07-656a-13d029a7f730@redhat.com> Date: Mon, 24 Apr 2023 13:51:16 +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> 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=-10.7 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_BARRACUDACENTRAL,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 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? > > 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