[COMMITTED,PR,tree-optimization/107052] range-ops: Pass nonzero masks through cast.
Message ID | 20221005122236.1579762-1-aldyh@redhat.com |
---|---|
State | New, archived |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp571391wrs; Wed, 5 Oct 2022 05:23:58 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6dADGxwj2rBPadKZfk5IPV2qHSrvbO1+RLr778Gx3z+uecxlTOGizw1D0uQSGDsGIcxL87 X-Received: by 2002:a17:906:db03:b0:741:337e:3600 with SMTP id xj3-20020a170906db0300b00741337e3600mr23923960ejb.343.1664972638709; Wed, 05 Oct 2022 05:23:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664972638; cv=none; d=google.com; s=arc-20160816; b=GKn5tXjfIhiTzc+c2KYGDJ7r7q0MFOUf99OetxYYVFC50ivtWKl1x8SmgxrmF+CSf1 /9ifdUXPoRc7allsPrrhnUVvHH4vgubz+RmVPPVSgZeNexQG3VfwKZg/SHqx0dh2fMYW TuZmzEePDAOVWl+aclmMZ7hBf1B50NRmLFzX8hr70uGl07m9xkvniy/reJ9qrIwR7NVT mV3uyLo5weugin8E7V8SGfRUZF1AHp5dq78WT42C5r49WtWeLZPvG/Gi1otPsw884EH1 New7uEXDCxoi/6WIea82iFN7muxTqc1Xr7KgPHZErg1Hl3ecCp/LN3WySQvhNMbKkQg0 79Eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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=zQGAZ2WWv38f7FeLr1n4qrRXXg3uJ+ZOf2uYw4QSCvE=; b=Yg4OwQUWaobpFkIDF1KY+X2rcBGe8PyE1Zpps1u406vfgUD6jQNYOzGVK6Pfm0KLM/ Osciax8ixkqJdorWUBd5DJ9WQI8xtmT/FOpHWlQHWJ8Z+fe6YbfR3r3FFQAe2un+Kgmr uoEyRelxSeWMQqjj1dAyesEkxtRMBVUb4eYaYWYDN4+NnZAodgX4Jg9rerrVLiRecCMB MWj7M/7yNJGdeETK7PAqwt/9Y7+MCzT0mvLe6yeTquBjlkM6D+FJIttdtMx8jiHtLIZJ ggIzI9/9xrnQ4M2MWhlaBoOoGUqyzVUWH1+Y5LZaGUEnavAKifapixfLi2ZouA/0ZNYD mCng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=kAaNi8rj; 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id h14-20020a17090619ce00b0072b40bc7412si9988217ejd.223.2022.10.05.05.23.58 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Oct 2022 05:23:58 -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=kAaNi8rj; 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 F2806385734B for <ouuuleilei@gmail.com>; Wed, 5 Oct 2022 12:23:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F2806385734B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664972635; bh=zQGAZ2WWv38f7FeLr1n4qrRXXg3uJ+ZOf2uYw4QSCvE=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=kAaNi8rj7Z8tlZh8gYAzibon1F0Q2Izfw1XvQMc6TS2lCKbsI4o3fenbvUAecePQl fdYqjFUzsBTv5192CVtqOZDc5P8I3weH6sIzf9SqUiLn4l4XoSB0lTfMIXCNSV+A+X Lj68qEvbrACPLeC7ywgY98rFHy4K3vprUDuMnan4= 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.129.124]) by sourceware.org (Postfix) with ESMTPS id EE30F385734B for <gcc-patches@gcc.gnu.org>; Wed, 5 Oct 2022 12:22:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EE30F385734B 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-561-b7Au1hAMPiOm2tYwRXV_YQ-1; Wed, 05 Oct 2022 08:22:48 -0400 X-MC-Unique: b7Au1hAMPiOm2tYwRXV_YQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7A7931C0CE63 for <gcc-patches@gcc.gnu.org>; Wed, 5 Oct 2022 12:22:48 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.194.34]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2AFE62028DC1; Wed, 5 Oct 2022 12:22:40 +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 295CMbpL1579778 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 5 Oct 2022 14:22:37 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.17.1/8.17.1/Submit) id 295CMbD61579777; Wed, 5 Oct 2022 14:22:37 +0200 To: GCC patches <gcc-patches@gcc.gnu.org> Subject: [COMMITTED] [PR tree-optimization/107052] range-ops: Pass nonzero masks through cast. Date: Wed, 5 Oct 2022 14:22:35 +0200 Message-Id: <20221005122236.1579762-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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=-12.3 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_LOW, SPF_HELO_NONE, SPF_NONE, TXREP 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 <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Aldy Hernandez via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Aldy Hernandez <aldyh@redhat.com> Cc: drepper@redhat.com Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1745850286977014998?= X-GMAIL-MSGID: =?utf-8?q?1745850349601260674?= |
Series |
[COMMITTED,PR,tree-optimization/107052] range-ops: Pass nonzero masks through cast.
|
|
Commit Message
Aldy Hernandez
Oct. 5, 2022, 12:22 p.m. UTC
Track nonzero masks through a cast in range-ops. We could also track through a truncating cast if the mask fits in the outer type. I will do that as a follow-up patch because I already have this patchset tested. PR tree-optimization/107052 gcc/ChangeLog: * range-op.cc (operator_cast::fold_range): Set nonzero mask. --- gcc/range-op.cc | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/gcc/range-op.cc b/gcc/range-op.cc index 4f647abd91c..6fa27a8904e 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -2515,6 +2515,14 @@ operator_cast::fold_range (irange &r, tree type ATTRIBUTE_UNUSED, if (r.varying_p ()) return true; } + + // Pass nonzero mask through the cast. + if (!truncating_cast_p (inner, outer)) + { + wide_int nz = inner.get_nonzero_bits (); + nz = wide_int::from (nz, TYPE_PRECISION (type), TYPE_SIGN (inner.type ())); + r.set_nonzero_bits (nz); + } return true; }