From patchwork Fri Nov 1 01:45:47 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Schmidt X-Patchwork-Id: 287690 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id F044F2C0343 for ; Fri, 1 Nov 2013 12:45:38 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:subject:from:to:cc:date:content-type :content-transfer-encoding:mime-version; q=dns; s=default; b=dAp re7JY2KWPYFyuJAXeVnM53y7XCsTJO6xN1S2LepxgVwlFdDXaG0+ib4aTJLubgv+ slP8+UCsFjxpoRz3a0KSUI6Woway5fqDgNlnID7Him3PrXAMgpR8Aab7aEERKrMa 2GruwjM7WrqjyCtcU1VuqMNfRIXVIe9SBaOafTlQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:subject:from:to:cc:date:content-type :content-transfer-encoding:mime-version; s=default; bh=TmTiVkBAO fzSrKEEmgCoFlzp834=; b=rEBPbl+7a7r+aPQes1E9HHHNNoSLS2P3S8yh7jo7j tTNFzG5U4Plb9nxbW4eSATOvtEZSAlnMScMcpuof5kKJ+GOYWZhyUizw8NxprnnK dF0MTTJttPoNIH2bhIKNlAhU42I4t8RlwSg4u5A+HoiUKQsDetn6ENACOh+dSuSl hI= Received: (qmail 24021 invoked by alias); 1 Nov 2013 01:45:31 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 24007 invoked by uid 89); 1 Nov 2013 01:45:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.2 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: e28smtp07.in.ibm.com Received: from e28smtp07.in.ibm.com (HELO e28smtp07.in.ibm.com) (122.248.162.7) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Fri, 01 Nov 2013 01:45:29 +0000 Received: from /spool/local by e28smtp07.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 1 Nov 2013 07:15:23 +0530 Received: from d28dlp02.in.ibm.com (9.184.220.127) by e28smtp07.in.ibm.com (192.168.1.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 1 Nov 2013 07:15:20 +0530 Received: from d28relay03.in.ibm.com (d28relay03.in.ibm.com [9.184.220.60]) by d28dlp02.in.ibm.com (Postfix) with ESMTP id 00D4E3940017 for ; Fri, 1 Nov 2013 07:14:58 +0530 (IST) Received: from d28av03.in.ibm.com (d28av03.in.ibm.com [9.184.220.65]) by d28relay03.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id rA11jDBr43516046 for ; Fri, 1 Nov 2013 07:15:14 +0530 Received: from d28av03.in.ibm.com (localhost [127.0.0.1]) by d28av03.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id rA11jJ63024095 for ; Fri, 1 Nov 2013 07:15:19 +0530 Received: from [9.49.145.112] (sig-9-49-145-112.mts.ibm.com [9.49.145.112]) by d28av03.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id rA11jH2B023990; Fri, 1 Nov 2013 07:15:18 +0530 Message-ID: <1383270347.6275.241.camel@gnopaine> Subject: [PATCH, rs6000] Fix rs6000_expand_vector_set for little endian From: Bill Schmidt To: gcc-patches@gcc.gnu.org Cc: dje.gcc@gmail.com Date: Thu, 31 Oct 2013 20:45:47 -0500 Mime-Version: 1.0 X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13110101-8878-0000-0000-00000982C40F X-IsSubscribed: yes Hi, Brooks Moses reported a bug with code that sets a single element of a vector to a given value and the rest of the vector to zero. This is implemented in rs6000_expand_vector_set, which uses a vperm instruction to place the nonzero value. As usual, we need to adjust the permute control vector and swap the order of the input operands. I added a test case based on the bug report. Bootstrapped and tested on powerpc64{,le}-unknown-linux-gnu with no regressions. The new test now passes for both endiannesses. Is this ok for trunk? Thanks, Bill gcc: 2013-10-31 Bill Schmidt * config/rs6000/rs6000.c (rs6000_expand_vector_set): Adjust for little endian. gcc/testsuite: 2013-10-31 Bill Schmidt * gcc.dg/vmx/vec-set.c: New. Index: gcc/testsuite/gcc.dg/vmx/vec-set.c =================================================================== --- gcc/testsuite/gcc.dg/vmx/vec-set.c (revision 0) +++ gcc/testsuite/gcc.dg/vmx/vec-set.c (revision 0) @@ -0,0 +1,14 @@ +#include "harness.h" + +vector short +vec_set (short m) +{ + return (vector short){m, 0, 0, 0, 0, 0, 0, 0}; +} + +static void test() +{ + check (vec_all_eq (vec_set (7), + ((vector short){7, 0, 0, 0, 0, 0, 0, 0})), + "vec_set"); +} Index: gcc/config/rs6000/rs6000.c =================================================================== --- gcc/config/rs6000/rs6000.c (revision 204192) +++ gcc/config/rs6000/rs6000.c (working copy) @@ -5529,10 +5529,27 @@ rs6000_expand_vector_set (rtx target, rtx val, int XVECEXP (mask, 0, elt*width + i) = GEN_INT (i + 0x10); x = gen_rtx_CONST_VECTOR (V16QImode, XVEC (mask, 0)); - x = gen_rtx_UNSPEC (mode, - gen_rtvec (3, target, reg, - force_reg (V16QImode, x)), - UNSPEC_VPERM); + + if (!BYTES_BIG_ENDIAN) + { + /* Invert selector. */ + rtx splat = gen_rtx_VEC_DUPLICATE (V16QImode, + gen_rtx_CONST_INT (QImode, -1)); + rtx tmp = gen_reg_rtx (V16QImode); + emit_move_insn (tmp, splat); + x = gen_rtx_MINUS (V16QImode, tmp, force_reg (V16QImode, x)); + emit_move_insn (tmp, x); + + /* Permute with operands reversed and adjusted selector. */ + x = gen_rtx_UNSPEC (mode, gen_rtvec (3, reg, target, tmp), + UNSPEC_VPERM); + } + else + x = gen_rtx_UNSPEC (mode, + gen_rtvec (3, target, reg, + force_reg (V16QImode, x)), + UNSPEC_VPERM); + emit_insn (gen_rtx_SET (VOIDmode, target, x)); }