From patchwork Fri Aug 3 20:47:25 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Glisse X-Patchwork-Id: 175046 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]) by ozlabs.org (Postfix) with SMTP id C7B152C0092 for ; Sat, 4 Aug 2012 06:47:47 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1344631668; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Date:From:To:Subject:Message-ID:User-Agent:MIME-Version: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=+d0PLxf QyDvSDLKDbuTWCdcvWQw=; b=wMnnoQdeDAmrdHcKfl1rmOjvzcGRkkIcPLx3C7G M08eaSu70nR0UYfdsNnVq5kkVORrBhWXfPaigQXw0ZhZN3O3TXh7tsaPfT1rzdtW Mbm5lLOe1c0AJHD42xMIF6RLd0Iv0v4oOmVso0Z+7aLjmSPr6/EnOeNYVr7sRPRD BZcU= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Date:From:To:Subject:Message-ID:User-Agent:MIME-Version:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=ZEW6qI7umQx51aIaauP7iXLp/f+uUrppx2f8r4ilZ0h+g5SwL7zcJ9yX++zoi6 2wqyETZixplyIellFDhIBfoRiGXrB0FS03tInt0ma7BngxDRrJA3wtOx+rRHyWe7 G9yPimPxh4HjafCQ4NrFcVtsjlovldSQQW7HszxJgyfQ8=; Received: (qmail 8795 invoked by alias); 3 Aug 2012 20:47:43 -0000 Received: (qmail 8778 invoked by uid 22791); 3 Aug 2012 20:47:42 -0000 X-SWARE-Spam-Status: No, hits=-6.8 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, TW_AV, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail4-relais-sop.national.inria.fr (HELO mail4-relais-sop.national.inria.fr) (192.134.164.105) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 03 Aug 2012 20:47:27 +0000 Received: from stedding.saclay.inria.fr ([193.55.250.194]) by mail4-relais-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES128-SHA; 03 Aug 2012 22:47:26 +0200 Received: from glisse (helo=localhost) by stedding.saclay.inria.fr with local-esmtp (Exim 4.80) (envelope-from ) id 1SxOmL-0003DA-R8 for gcc-patches@gcc.gnu.org; Fri, 03 Aug 2012 22:47:25 +0200 Date: Fri, 3 Aug 2012 22:47:25 +0200 (CEST) From: Marc Glisse To: gcc-patches@gcc.gnu.org Subject: [rtl, i386] combine concat+permutation Message-ID: User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 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 Hello, this is a follow up to the patch applied after this discussion: http://gcc.gnu.org/ml/gcc-patches/2012-05/msg00504.html It handles the -mavx __builtin_shuffle case mentioned there. It passes bootstrap (languages=c,c++) and regtest on x86_64. 2012-08-04 Marc Glisse gcc/ * simplify-rtx.c (simplify_binary_operation_1): Optimize shuffle of a concatenation. gcc/testsuite/ * gcc.target/i386/perm-concat.c: New test. Index: gcc/testsuite/gcc.target/i386/perm-concat.c =================================================================== --- gcc/testsuite/gcc.target/i386/perm-concat.c (revision 0) +++ gcc/testsuite/gcc.target/i386/perm-concat.c (revision 0) @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O -mavx -mfpmath=sse" } */ + +typedef double v2df __attribute__ ((__vector_size__ (16))); + +v2df +f (double d) +{ + v2df x = {-d, d}; + return __builtin_ia32_vpermilpd (x, 1); +} + +/* { dg-final { scan-assembler-not "\tvpermilpd\[ \t\]" } } */ Property changes on: gcc/testsuite/gcc.target/i386/perm-concat.c ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision URL Added: svn:eol-style + native Index: gcc/simplify-rtx.c =================================================================== --- gcc/simplify-rtx.c (revision 190127) +++ gcc/simplify-rtx.c (working copy) @@ -3235,40 +3235,57 @@ simplify_binary_operation_1 (enum rtx_co /* If we build {a,b} then permute it, build the result directly. */ if (XVECLEN (trueop1, 0) == 2 && CONST_INT_P (XVECEXP (trueop1, 0, 0)) && CONST_INT_P (XVECEXP (trueop1, 0, 1)) && GET_CODE (trueop0) == VEC_CONCAT && GET_CODE (XEXP (trueop0, 0)) == VEC_CONCAT && GET_MODE (XEXP (trueop0, 0)) == mode && GET_CODE (XEXP (trueop0, 1)) == VEC_CONCAT && GET_MODE (XEXP (trueop0, 1)) == mode) { unsigned int i0 = INTVAL (XVECEXP (trueop1, 0, 0)); unsigned int i1 = INTVAL (XVECEXP (trueop1, 0, 1)); rtx subop0, subop1; gcc_assert (i0 < 4 && i1 < 4); subop0 = XEXP (XEXP (trueop0, i0 / 2), i0 % 2); subop1 = XEXP (XEXP (trueop0, i1 / 2), i1 % 2); return simplify_gen_binary (VEC_CONCAT, mode, subop0, subop1); } + + if (XVECLEN (trueop1, 0) == 2 + && CONST_INT_P (XVECEXP (trueop1, 0, 0)) + && CONST_INT_P (XVECEXP (trueop1, 0, 1)) + && GET_CODE (trueop0) == VEC_CONCAT + && GET_MODE (trueop0) == mode) + { + unsigned int i0 = INTVAL (XVECEXP (trueop1, 0, 0)); + unsigned int i1 = INTVAL (XVECEXP (trueop1, 0, 1)); + rtx subop0, subop1; + + gcc_assert (i0 < 2 && i1 < 2); + subop0 = XEXP (trueop0, i0); + subop1 = XEXP (trueop0, i1); + + return simplify_gen_binary (VEC_CONCAT, mode, subop0, subop1); + } } if (XVECLEN (trueop1, 0) == 1 && CONST_INT_P (XVECEXP (trueop1, 0, 0)) && GET_CODE (trueop0) == VEC_CONCAT) { rtx vec = trueop0; int offset = INTVAL (XVECEXP (trueop1, 0, 0)) * GET_MODE_SIZE (mode); /* Try to find the element in the VEC_CONCAT. */ while (GET_MODE (vec) != mode && GET_CODE (vec) == VEC_CONCAT) { HOST_WIDE_INT vec_size = GET_MODE_SIZE (GET_MODE (XEXP (vec, 0))); if (offset < vec_size) vec = XEXP (vec, 0); else { offset -= vec_size; vec = XEXP (vec, 1);