From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id C17333858D28 for ; Thu, 26 Jan 2023 12:52:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C17333858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 05C811FF65; Thu, 26 Jan 2023 12:52:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1674737553; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=IxpN2XBuzegNNnQhbjXycz4+vgIljDhpoGLzIuGEZ7I=; b=P3cxBm08tW+MBQeMa9dSumVodYCXtgzgPzrzaXudVs7XIJ1M+UkxEQoyXXrNcyA4HxJh7t bNNNq88xyW1b+9n4rAwMVnitFknQpZh59Qjnpf2LQuRWV8LV2QOD6jTqkbshA7j4bphkb3 RWbYcGpqEK71qw6+gpc/e0qNd+0Yg2I= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1674737553; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=IxpN2XBuzegNNnQhbjXycz4+vgIljDhpoGLzIuGEZ7I=; b=OZhXtEwT6AkSL9rJgx+xFI+/XIIKmgklzNaA4cXLhYYnHRkHA6avOjrK+km/QBWNzJn7lo AjcPfHW6vHORTsBA== Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id F28312C141; Thu, 26 Jan 2023 12:52:32 +0000 (UTC) Date: Thu, 26 Jan 2023 12:52:32 +0000 (UTC) From: Richard Biener To: Jakub Jelinek cc: Andrew MacLeod , Aldy Hernandez , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] value-relation: Small tweaks to tables In-Reply-To: Message-ID: References: User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS,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 List-Id: On Thu, 26 Jan 2023, Jakub Jelinek wrote: > 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? OK. Richard. > 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. > > --- 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)) > > Jakub > > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman; HRB 36809 (AG Nuernberg)