From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 119335 invoked by alias); 29 Aug 2017 13:31:58 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 119317 invoked by uid 89); 29 Aug 2017 13:31:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=his X-HELO: gate.crashing.org Received: from gate.crashing.org (HELO gate.crashing.org) (63.228.1.57) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 29 Aug 2017 13:31:46 +0000 Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.13.8) with ESMTP id v7TDVf8k020568; Tue, 29 Aug 2017 08:31:41 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id v7TDVdJl020566; Tue, 29 Aug 2017 08:31:39 -0500 Date: Tue, 29 Aug 2017 14:13:00 -0000 From: Segher Boessenkool To: Michael Meissner , GCC Patches , David Edelsohn , Bill Schmidt Subject: Re: [PATCH], PR target/82015, add PowerPC warning for unpack_vector_int128 with illegal 2nd argument Message-ID: <20170829133138.GK13471@gate.crashing.org> References: <20170829034147.GA15563@ibm-tiger.the-meissners.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170829034147.GA15563@ibm-tiger.the-meissners.org> User-Agent: Mutt/1.4.2.3i X-IsSubscribed: yes X-SW-Source: 2017-08/txt/msg01648.txt.bz2 Hi! On Mon, Aug 28, 2017 at 11:41:47PM -0400, Michael Meissner wrote: > One of the local programmers tried to use the __builtin_unpack_vector_int128 > function, but his second argument was not the constant 0 or 1. The compiler > put the 2nd argument into a register, but there wasn't a valid insn for this, > and raised an insn not found message. GCC should warn about this illegal > usage. Error, not warn (all the code is correct though). > * config/rs6000/rs6000.c (rs6000_expand_binop_builtin): Insure > that the second argument of the built-in functions to unpack > 128-bit scalar types to 64-bit values is 0 or 1. Change to use a > switch statement instead a lot of if statements. It usually is easier to review if you post the big mechanical changes as a separate patch. But I'll manage, this one isn't so bad :-) > @@ -14050,6 +14051,21 @@ rs6000_expand_binop_builtin (enum insn_c > error ("argument 2 must be a 7-bit unsigned literal"); > return CONST0_RTX (tmode); > } > + break; > + case CODE_FOR_unpackv1ti: > + case CODE_FOR_unpackkf: > + case CODE_FOR_unpacktf: > + case CODE_FOR_unpackif: > + case CODE_FOR_unpacktd: > + /* Only allow 1-bit unsigned literals. */ > + STRIP_NOPS (arg1); > + if (TREE_CODE (arg1) != INTEGER_CST > + || !IN_RANGE (TREE_INT_CST_LOW (arg1), 0, 1)) > + { > + error ("argument 2 must be 0 or 1"); > + return CONST0_RTX (tmode); > + } > + break; This loses that it must be a literal, compared to the 5/6/7 bit messages. Maybe just say "1-bit unsigned literal", it reads a little bit funny, but at least it is correct (for some meaning of "literal", anyway) ;-) Okay for trunk; okay for the release branches with the obvious changes. Thanks! Segher