From patchwork Wed Jul 13 14:26:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 236 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a98:d5ce:0:b0:178:cc93:bf7d with SMTP id g14csp285926eik; Wed, 13 Jul 2022 07:28:06 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tOY5syDVbXhneaEwANOj2VQhfYpumTc22ZeQqoJTZ//9YQDxGgv4mvm44aRNYLIgII0GTr X-Received: by 2002:a05:6402:2b88:b0:43a:6c58:6c64 with SMTP id fj8-20020a0564022b8800b0043a6c586c64mr5463061edb.348.1657722485973; Wed, 13 Jul 2022 07:28:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657722485; cv=none; d=google.com; s=arc-20160816; b=eQhgt/cnvmTKt4hB8yLL5/9iwcrW3agQ036TwTu9V3iIFUhAO0UwokxEUPscqg8KiV dtxyTARTaZIlzohLJPaavGQG5K1LtGQ1gcaQQUsXn8HnrdBz8Z1InQNLKRA6pcGMW4dV sFWg2sFRL2aY6b5ckYZLAyNiD7nUlHGOnHSPQU2F/WNudENQCMGZVgtzBMkwMzYlphXv p+qffP2x3CfbsIRveMTpnMhU1FNKvOflQBOrB7qW/P++qj5EztCKukXMOdJ1HTfsiTkV UHwnVpq3sYqoLqrQcrRjUtWRLU3jjqwEnBJwszD18bA035E73erHTtacwi6k04c1AjeA mK7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=In0J9kzTZqbQrjSnut97M8kr5ardNPjmUq9gDaaRtu0=; b=ydp79C9UMgzh4Qw5YE5hKP/0Y98AEuKO3GccmPqRYFgImlg7r6RgdvP5PhxaagJUa8 lA/hFs/Ygi+9iKiIo8FM4LpdiIRQvX2BRDYBHcfHHN2nmuC7qVFy1X2PYiWzwk/fXz+0 tmWDYvbSqULJAnvVQt84UUCfflhx7brwIlyYYoO+6oSEW96Odso72QQgC3cHm2WX5Lvt 2nIyn7IOUknO06TE9Nb930QJKoHPGeSc8PCxXI7kg5otpb+qNNbP9+jxWtirvnFuqcXF 4S4VUkzUgedddrukHChi93mRICB8862IcJEgUay1GoAZT0liybSljR/zYuEv9MIfpx4V 4XQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=yUxo93rh; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id rk27-20020a170907215b00b00727a08f5118si4413483ejb.702.2022.07.13.07.28.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Jul 2022 07:28:05 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=yUxo93rh; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 22D653838F19 for ; Wed, 13 Jul 2022 14:27:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 22D653838F19 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1657722477; bh=In0J9kzTZqbQrjSnut97M8kr5ardNPjmUq9gDaaRtu0=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=yUxo93rhSSGJ3qt8JbVRjEJ/WKp/wy2pqVAnpuJuvN17PMVIriobzx7t7UTj0ooLU 5ey6f5ZXMcccc4R/2yS/Bm2hSnHy/xsPnR2G3OQXVvGOs5bEC9j1KN9OHd2wdS5AB+ fhDUc74nZmxmi5Im1Z4CHpvYiibBAYGn/W+onyG8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 692573856DE5 for ; Wed, 13 Jul 2022 14:27:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 692573856DE5 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-656-6LBAKtiIOnq23JEnuwZ5zQ-1; Wed, 13 Jul 2022 10:27:11 -0400 X-MC-Unique: 6LBAKtiIOnq23JEnuwZ5zQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9843A29AA383 for ; Wed, 13 Jul 2022 14:27:11 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.195.134]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 310EF1121314; Wed, 13 Jul 2022 14:27:10 +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 26DER88o633763 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 13 Jul 2022 16:27:08 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.17.1/8.17.1/Submit) id 26DER87i633762; Wed, 13 Jul 2022 16:27:08 +0200 To: GCC patches Subject: [COMMITTED] Clear nonzero mask when inverting ranges. Date: Wed, 13 Jul 2022 16:26:18 +0200 Message-Id: <20220713142619.633492-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.2 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, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Aldy Hernandez via Gcc-patches From: Aldy Hernandez Reply-To: Aldy Hernandez Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1738248013666044840?= X-GMAIL-MSGID: =?utf-8?q?1738248013666044840?= Every time we set a range we should take into account the nonzero mask. This happens automatically for the set() methods, plus all the other assignment, intersect, and union methods. Unfortunately I forgot about the invert code. Also, for good measure I audited the rest of the setters in value_range.cc and plugged the legacy code to pessimize the masks to -1 for union/intersect, since we don't support the masks on them (or rather, we don't keep very good track of them). Tested on x86-64 Linux. gcc/ChangeLog: * value-range.cc (irange::copy_to_legacy): Set nonzero mask. (irange::legacy_intersect): Clear nonzero mask. (irange::legacy_union): Same. (irange::invert): Same. --- gcc/value-range.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gcc/value-range.cc b/gcc/value-range.cc index 2aa973b2af2..528ed547ef3 100644 --- a/gcc/value-range.cc +++ b/gcc/value-range.cc @@ -331,6 +331,7 @@ irange::copy_to_legacy (const irange &src) m_base[0] = src.m_base[0]; m_base[1] = src.m_base[1]; m_kind = src.m_kind; + m_nonzero_mask = src.m_nonzero_mask; return; } // Copy multi-range to legacy. @@ -1336,6 +1337,9 @@ irange::legacy_intersect (irange *vr0, const irange *vr1) intersect_ranges (&vr0kind, &vr0min, &vr0max, vr1->kind (), vr1->min (), vr1->max ()); + // Pessimize nonzero masks, as we don't support them. + m_nonzero_mask = NULL; + /* Make sure to canonicalize the result though as the inversion of a VR_RANGE can still be a VR_RANGE. */ if (vr0kind == VR_UNDEFINED) @@ -1657,6 +1661,9 @@ irange::legacy_union (irange *vr0, const irange *vr1) union_ranges (&vr0kind, &vr0min, &vr0max, vr1->kind (), vr1->min (), vr1->max ()); + // Pessimize nonzero masks, as we don't support them. + m_nonzero_mask = NULL; + if (vr0kind == VR_UNDEFINED) vr0->set_undefined (); else if (vr0kind == VR_VARYING) @@ -2253,6 +2260,7 @@ irange::invert () } gcc_checking_assert (!undefined_p () && !varying_p ()); + m_nonzero_mask = NULL; // We always need one more set of bounds to represent an inverse, so // if we're at the limit, we can't properly represent things.