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 C9A46385840B for ; Tue, 1 Feb 2022 22:17:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C9A46385840B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=kernel.crashing.org Authentication-Results: sourceware.org; spf=pass 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 211MGEW8015323; Tue, 1 Feb 2022 16:16:14 -0600 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 211MGDKR015322; Tue, 1 Feb 2022 16:16:13 -0600 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Tue, 1 Feb 2022 16:16:13 -0600 From: Segher Boessenkool To: Bill Schmidt Cc: gcc-patches@gcc.gnu.org, dje.gcc@gmail.com Subject: Re: [PATCH v2 3/8] rs6000: Unify error messages for built-in constant restrictions Message-ID: <20220201221613.GW614@gate.crashing.org> References: <20220128232420.GJ614@gate.crashing.org> <94c9c8b9-bb8c-ffbe-cabd-f85d54b02440@linux.ibm.com> <20220131172813.GL614@gate.crashing.org> <0bf9e765-1180-6485-a296-59d86fb7728f@linux.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0bf9e765-1180-6485-a296-59d86fb7728f@linux.ibm.com> User-Agent: Mutt/1.4.2.3i X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Tue, 01 Feb 2022 22:17:15 -0000 On Tue, Feb 01, 2022 at 08:53:52AM -0600, Bill Schmidt wrote: > As discussed, I simplified this patch by just changing how the error > message is produced: > > We currently give different error messages for built-in functions that > violate range restrictions on their arguments, depending on whether we > record them as requiring an n-bit literal or a literal between two values. > It's better to be consistent. Change the error message for the n-bit > literal to look like the other one. > --- a/gcc/config/rs6000/rs6000-call.cc > +++ b/gcc/config/rs6000/rs6000-call.cc > @@ -5729,8 +5729,10 @@ rs6000_expand_builtin (tree exp, rtx target, rtx /* subtarget */, > if (!(TREE_CODE (restr_arg) == INTEGER_CST > && (TREE_INT_CST_LOW (restr_arg) & ~mask) == 0)) > { > - error ("argument %d must be a %d-bit unsigned literal", > - bifaddr->restr_opnd[i], bifaddr->restr_val1[i]); > + unsigned p = ((unsigned) 1 << bifaddr->restr_val1[i]) - 1; Don't write (unsigned) 1 but instead just 1U please. Does it need to be 1ULL btw? (You need this if restr_val1[i] can be greater than or equal to 32). (32 itself would work, but is UB nevertheless). Okay with that. Thanks! Segher