From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by sourceware.org (Postfix) with ESMTP id 9B430385780C for ; Wed, 2 Jun 2021 22:45:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9B430385780C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=kernel.crashing.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=kernel.crashing.org Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 152Mi0vD004067; Wed, 2 Jun 2021 17:44:00 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 152Mi06Z004066; Wed, 2 Jun 2021 17:44:00 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Wed, 2 Jun 2021 17:43:59 -0500 From: Segher Boessenkool To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: Re: [PATCH] rtl: constm64_rtx..const64_rtx Message-ID: <20210602224359.GL18427@gate.crashing.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i X-Spam-Status: No, score=-6.3 required=5.0 tests=BAYES_00, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, TXREP, T_SPF_HELO_PERMERROR, T_SPF_PERMERROR autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-List-Received-Date: Wed, 02 Jun 2021 22:45:05 -0000 Hi! On Wed, Jun 02, 2021 at 06:07:28PM +0100, Richard Sandiford wrote: > Segher Boessenkool writes: > > Since times immemorial there has been const_int_rtx for all values from > > -64 to 64, but only constm1_rtx..const2_rtx have been available for > > convenient use. Change this, so that we can use all values in > > {-64,...,64} in RTL easily. This matters, because then we we just say > > if (XEXP (x, 1) == const16_rtx) > > and things like that, since all const_int in that range are unique. We > > already do for -1, 0, 1, 2, but we could for everything. > No strong objection, but personally I'd rather not add something > that is very specific to VOIDmode CONST_INTs. I realise it's very > unlikely that we'll ever be able to give CONST_INTs their proper mode > (no-one has the kind of time needed to do that), but I don't think we > should make the switch actively harder either. How does this make that harder? Having no mode for CONST_INTs makes some things significantly *easier* btw. Well you know that, that is what makes any conversion away from this so much harder :-) We have has const0_rtx etc. since forever, this patch just increases the range (to those values that have had guaranteed unique RTXes since decades as well). > How about adding a new inline helper function that tests whether an > rtx is a CONST_INT with a given value? Then we could have a > __builtin_constant_p shortcut for the [-64, 64] case. That would > also avoid hard-coding the range. Currently you have to write the example as if (XEXP (x, 1) == const_int_rtx[MAX_SAVED_CONST_INT + 16]) and with your suggestion it will be if (is_const_int_with_value (XEXP (x, 1), 16)) I like if (XEXP (x, 1) == const16_rtx) better: it is shorter and clearer (often you have something like this is more complex conditionals, it matters), and this pattern is already very well known (for -1, 0, 1, 2). Do you like this patch a bit better if I also add such an is_const_int_with_value function? Segher