From patchwork Thu Jan 26 10:23:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 48560 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp200322wrn; Thu, 26 Jan 2023 02:24:48 -0800 (PST) X-Google-Smtp-Source: AMrXdXsu5loqmqWn8kHlFNMOkGJXbY1xnpYGHm81B36vBgMRp2yVFNCH2pwvUm7frbdA2zptzmo9 X-Received: by 2002:a05:6402:2405:b0:49d:1a59:176b with SMTP id t5-20020a056402240500b0049d1a59176bmr42193536eda.30.1674728688668; Thu, 26 Jan 2023 02:24:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674728688; cv=none; d=google.com; s=arc-20160816; b=cDlJ0CM8LxDZyEKYeM7O662QVVnsfWKpYDFoGKAUwAFwgDgwM0zQuc1sZa3zIy5yb1 BE6lwmi8I5ntphkeGeY00bXvNLX+0UWSqvsN+j66I0ZvuDYm3omlaHKdfJzC5ZLy3b34 /ELm716g6epklpzeaUe35bhM6UnvRsosJSqBHggkhdOmjP5cnjywazizogp8/uai0pqO KUCnluuw/iLG75BgJ3/xHmxSxbAyBwPsUp09rYP2Un0hqsovBaaBpSuesJkOXHhRMuCx BiV1bHiXrso8LR4kKDabdUEkKtFB45F/StoauFXfouznbTJ4wYUybrzBnVoyp/DR66Nl SDxg== 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-disposition:mime-version:message-id:subject:cc:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=264R21HwHaiB8Q4JKooCzBpwUfIkafjWejBQvkiYlNY=; b=mY5Di4Osd5BFVY/7K+KjYyUfH9xMkpRQRlU55X++GeWA+8EvaK6CXBtpCPC7i4MxPX fBV2Tp45IGrQmqpZvAiF/2jNiKstaATbq8u//NQqpWAPSJcOLj3VqHkZ1nK5Y+bE/XGu Ce0nq05Ux4CSNgS/mMOwpHT7XRU0QnxDc6ipW6DlTv6me4R+o9wsQNNPGsIeoilKDWLr Ru+DaD1PGd8Vw4uRe7aWto3tiY5Dzn2sEC+SpG9K9MJYMy1K1/N1Q7OQxiwZv00DqPJU JCYYr/0oprnLF5kCrNhF9CKtI1OcRTx8bfoHueJ1hMm7cjMK59ZFdN1rYQ+TiQqN5Wxb v3IQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="JnRlb+/+"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id cw16-20020a056402229000b0049d8416507dsi1300439edb.292.2023.01.26.02.24.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Jan 2023 02:24:48 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="JnRlb+/+"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 694ED3858C2F for ; Thu, 26 Jan 2023 10:24:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 694ED3858C2F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1674728687; bh=264R21HwHaiB8Q4JKooCzBpwUfIkafjWejBQvkiYlNY=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=JnRlb+/+Ja/diwLvl6OrKGYqMohnwcFbIKYcZhYfZJ72zxVJTY9oPuMp1/fjW6VbK mo5UwnH0nhKTe4wA6pB2+naLNji9elmUU/A7s+bmf+s5ZVlECCx9UTgCCIGN0WaSWj ZTDirPfIbRMmysNhPsRSlP9rZ0oCr5whafxy3D+w= 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 8352A3858D28 for ; Thu, 26 Jan 2023 10:24:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8352A3858D28 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-675-PgdkULueMWW-8KBZiyVkmw-1; Thu, 26 Jan 2023 05:24:00 -0500 X-MC-Unique: PgdkULueMWW-8KBZiyVkmw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4F903858F09; Thu, 26 Jan 2023 10:24:00 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.223]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0C6BB51E5; Thu, 26 Jan 2023 10:23:59 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 30QANvG4607652 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 26 Jan 2023 11:23:57 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 30QANusn607651; Thu, 26 Jan 2023 11:23:56 +0100 Date: Thu, 26 Jan 2023 11:23:56 +0100 To: Andrew MacLeod , Aldy Hernandez , Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] value-relation: Small tweaks to tables Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek 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?1756080309480891520?= X-GMAIL-MSGID: =?utf-8?q?1756080309480891520?= Hi! As I said earlier, all these tables are used solely in value-relation.cc and never modified, plus because VREL_LAST is small especially the two-dimensional arrays are vast a lot of .data (or .rodata) space - 576 bytes each. The following patch makes those arrays static const and uses unsigned char instead of relation_kind so that the two-dimensional arrays shrink to 144 bytes. Build-tested, ok for trunk if it passes bootstrap/regtest? 2023-01-26 Jakub Jelinek * value-relation.cc (kind_string): Add const. (rr_negate_table, rr_swap_table, rr_intersect_table, rr_union_table, rr_transitive_table): Add static const, change element type from relation_kind to unsigned char. (relation_negate, relation_swap, relation_intersect, relation_union, relation_transitive): Cast rr_*_table element to relation_kind. (relation_to_code): Add static const. (relation_tests): Assert VREL_LAST is smaller than UCHAR_MAX. Jakub --- gcc/value-relation.cc.jj 2023-01-19 23:26:31.887212157 +0100 +++ gcc/value-relation.cc 2023-01-26 11:12:42.798750916 +0100 @@ -32,7 +32,7 @@ along with GCC; see the file COPYING3. #include "alloc-pool.h" #include "dominance.h" -static const char *kind_string[VREL_LAST] = +static const char *const kind_string[VREL_LAST] = { "varying", "undefined", "<", "<=", ">", ">=", "==", "!=", "pe8", "pe16", "pe32", "pe64" }; @@ -45,7 +45,7 @@ print_relation (FILE *f, relation_kind r } // This table is used to negate the operands. op1 REL op2 -> !(op1 REL op2). -relation_kind rr_negate_table[VREL_LAST] = { +static const unsigned char rr_negate_table[VREL_LAST] = { VREL_VARYING, VREL_UNDEFINED, VREL_GE, VREL_GT, VREL_LE, VREL_LT, VREL_NE, VREL_EQ }; @@ -54,11 +54,11 @@ relation_kind rr_negate_table[VREL_LAST] relation_kind relation_negate (relation_kind r) { - return rr_negate_table [r]; + return relation_kind (rr_negate_table [r]); } // This table is used to swap the operands. op1 REL op2 -> op2 REL op1. -relation_kind rr_swap_table[VREL_LAST] = { +static const unsigned char rr_swap_table[VREL_LAST] = { VREL_VARYING, VREL_UNDEFINED, VREL_GT, VREL_GE, VREL_LT, VREL_LE, VREL_EQ, VREL_NE }; @@ -67,12 +67,12 @@ relation_kind rr_swap_table[VREL_LAST] = relation_kind relation_swap (relation_kind r) { - return rr_swap_table [r]; + return relation_kind (rr_swap_table [r]); } // This table is used to perform an intersection between 2 relations. -relation_kind rr_intersect_table[VREL_LAST][VREL_LAST] = { +static const unsigned char rr_intersect_table[VREL_LAST][VREL_LAST] = { // VREL_VARYING { VREL_VARYING, VREL_UNDEFINED, VREL_LT, VREL_LE, VREL_GT, VREL_GE, VREL_EQ, VREL_NE }, @@ -104,13 +104,13 @@ relation_kind rr_intersect_table[VREL_LA relation_kind relation_intersect (relation_kind r1, relation_kind r2) { - return rr_intersect_table[r1][r2]; + return relation_kind (rr_intersect_table[r1][r2]); } // This table is used to perform a union between 2 relations. -relation_kind rr_union_table[VREL_LAST][VREL_LAST] = { +static const unsigned char rr_union_table[VREL_LAST][VREL_LAST] = { // VREL_VARYING { VREL_VARYING, VREL_VARYING, VREL_VARYING, VREL_VARYING, VREL_VARYING, VREL_VARYING, VREL_VARYING, VREL_VARYING }, @@ -141,14 +141,14 @@ relation_kind rr_union_table[VREL_LAST][ relation_kind relation_union (relation_kind r1, relation_kind r2) { - return rr_union_table[r1][r2]; + return relation_kind (rr_union_table[r1][r2]); } // This table is used to determine transitivity between 2 relations. // (A relation0 B) and (B relation1 C) implies (A result C) -relation_kind rr_transitive_table[VREL_LAST][VREL_LAST] = { +static const unsigned char rr_transitive_table[VREL_LAST][VREL_LAST] = { // VREL_VARYING { VREL_VARYING, VREL_VARYING, VREL_VARYING, VREL_VARYING, VREL_VARYING, VREL_VARYING, VREL_VARYING, VREL_VARYING }, @@ -180,12 +180,12 @@ relation_kind rr_transitive_table[VREL_L relation_kind relation_transitive (relation_kind r1, relation_kind r2) { - return rr_transitive_table[r1][r2]; + return relation_kind (rr_transitive_table[r1][r2]); } // This vector maps a relation to the equivalent tree code. -tree_code relation_to_code [VREL_LAST] = { +static const tree_code relation_to_code [VREL_LAST] = { ERROR_MARK, ERROR_MARK, LT_EXPR, LE_EXPR, GT_EXPR, GE_EXPR, EQ_EXPR, NE_EXPR }; @@ -1727,6 +1727,8 @@ namespace selftest void relation_tests () { + // rr_*_table tables use unsigned char rather than relation_kind. + ASSERT_LT (VREL_LAST, UCHAR_MAX); // Verify commutativity of relation_intersect and relation_union. for (relation_kind r1 = VREL_VARYING; r1 < VREL_PE8; r1 = relation_kind (r1 + 1))