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 B0BAA3858D32 for ; Mon, 24 Apr 2023 07:43:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B0BAA3858D32 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=1682322221; 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; bh=ZI/fDuDwvCQ3FrPD05dLjzmtQqRTSz06Ec2J+xN0JY4=; b=Ovqczx+ktQuRUTH4ZzYDe3QMd2dtP+rGzc82NP2GGIEbhrM9z31AZ4huCJktTncica5L4j mgGv/pewW7dteDVRaWURK5sVFSeLB0k/ZAoaITIDRvljxOmuA7lLrPg6wA5ES2+SkkdTJM v3pUZakbUv89RqNa7nb9UTL0tRumA5o= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-556-6ZEOvs0wOMacApCs5v9VYw-1; Mon, 24 Apr 2023 03:43:39 -0400 X-MC-Unique: 6ZEOvs0wOMacApCs5v9VYw-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8EAA6800047 for ; Mon, 24 Apr 2023 07:43:39 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.193.172]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 35DDE492B03; Mon, 24 Apr 2023 07:43:39 +0000 (UTC) Received: from abulafia.quesejoda.com (localhost [127.0.0.1]) by abulafia.quesejoda.com (8.17.1/8.17.1) with ESMTPS id 33O7haUC141918 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 24 Apr 2023 09:43:37 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.17.1/8.17.1/Submit) id 33O7hafB141917; Mon, 24 Apr 2023 09:43:36 +0200 From: Aldy Hernandez To: GCC patches Cc: Andrew MacLeod , Aldy Hernandez Subject: [PATCH] Pass correct type to irange::contains_p() in ipa-cp.cc. Date: Mon, 24 Apr 2023 09:43:32 +0200 Message-Id: <20230424074332.141890-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-11.4 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_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: 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); + return r.contains_p (val); +} + /* Decide whether and what specialized clones of NODE should be created. */ static bool @@ -6221,7 +6234,8 @@ decide_whether_version_node (struct cgraph_node *node) supports this only for integers now. */ if (TREE_CODE (val->value) == INTEGER_CST && !plats->m_value_range.bottom_p () - && !plats->m_value_range.m_vr.contains_p (val->value)) + && !ipa_range_contains_p (plats->m_value_range.m_vr, + val->value)) { /* This can happen also if a constant present in the source code falls outside of the range of parameter's type, so we -- 2.40.0