From patchwork Thu Jan 25 10:09:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 865804 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-472009-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="bm7XawY1"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zRySf2SSKz9s72 for ; Thu, 25 Jan 2018 21:09:37 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=IMKWNH9mUITcToyraXrwvUZHm0MxX9IpSlhSm9X46vZRVbTH9y +tnoRjsWhuEjVjm4E55lIkcypoFNNyM4sGWyr6a8sgjQYtWOlBSap3WoUKK6Fz/h cd/RvWPeHMy5UUb4EskdltIDShqWmKOpR/yANQZEu8PBkig4lbVn4DMB8= 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:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=sAMa61OPsdOCRCuTnNbGPnoNDs8=; b=bm7XawY1NDJR+UKffxMu J4tj3bZmOG6fOlKJxeuLadKTqzL7H8cnmid7fuIyKYhhnOXJXQIME9XcWk0A1kjj ZMpKYTLBRLPoBt3lym6tUUftLKbSHehcQL62GMZ8gZp/d8pve8urYsKVC/dvMvaW 6TlJU32VeyOdQWT7XRedNuY= Received: (qmail 57497 invoked by alias); 25 Jan 2018 10:09:30 -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 57487 invoked by uid 89); 25 Jan 2018 10:09:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.8 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=xm, 7417 X-HELO: mail-pg0-f46.google.com Received: from mail-pg0-f46.google.com (HELO mail-pg0-f46.google.com) (74.125.83.46) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 25 Jan 2018 10:09:28 +0000 Received: by mail-pg0-f46.google.com with SMTP id o13so4766000pgs.2 for ; Thu, 25 Jan 2018 02:09:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=QD33NbeAmYafdAbxsWW7HGOLGqVb+0q67ZXw+R1LA/Q=; b=lc2s5XYmY/4TVexHphwPNTGTyJ8BM0In2Cx0xmSjqfuqo98CBJJGWASMQjxVFfzX+Y GuuB/4cxbpdkh/KpDIYfBIDd8W2HcOW+T+vGHHcUGhw9RFQhKpMXs5dfKJbRUDeLTQx5 SgGxTw4u0032R1unM3R6Bc3hqODh7lH/ceKCFdp7oCgLXFfbNW0tkCBnyk5hTF+umfzb t11jQ3Ha0CieWlsbf106Qu0HVrEisPW6AHab8+SsiEd3nBOH6ifxBRRzW8g6qvY165oW SwSMeX98I+bauYnRPopm7AsYG5tK0XkB9C9PebTH9ilzJ/fneedgzh3EaPVPkmbCSCo9 rzRw== X-Gm-Message-State: AKwxytcixAInSVnQQp+jAw4umVUBzh7z+Ey9p1eEMyRIcAmw2In9B7zb Ah57qYhjMjusMznJSj7kuG2wcw== X-Google-Smtp-Source: AH8x2261kJw557glQ5Lzivr3pI3+mCKjNEAVRFnLTCPwUonrVmI8BmmFL8ebQPGNtXnc/nSDc/IyxQ== X-Received: by 10.98.10.79 with SMTP id s76mr15274769pfi.63.1516874966304; Thu, 25 Jan 2018 02:09:26 -0800 (PST) Received: from bubble.grove.modra.org (CPE-58-175-244-173.hdcz1.win.bigpond.net.au. [58.175.244.173]) by smtp.gmail.com with ESMTPSA id r84sm15112726pfk.92.2018.01.25.02.09.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Jan 2018 02:09:25 -0800 (PST) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id AFBB1C1729; Thu, 25 Jan 2018 20:39:21 +1030 (ACDT) Date: Thu, 25 Jan 2018 20:39:21 +1030 From: Alan Modra To: gcc-patches@gcc.gnu.org Cc: Segher Boessenkool Subject: PR84033, powerpc64le -moptimize-swaps bad code with vec_vbpermq Message-ID: <20180125100921.GV20622@bubble.grove.modra.org> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-IsSubscribed: yes vbpermq produces its output in bits 48..63 of the target vector reg, so the output cannot be lane swapped. Bootstrapped and regression tested powerpc64le-linux. OK to apply mainline, and backport to the branches? gcc/ PR target/84033 * config/rs6000/rs6000-p8swap.c (rtx_is_swappable_p): Exclude UNSPEC_VBPERMQ. Sort other unspecs. gcc/testsuite/ PR target/84033 * gcc.target/powerpc/swaps-p8-46.c: New. diff --git a/gcc/config/rs6000/rs6000-p8swap.c b/gcc/config/rs6000/rs6000-p8swap.c index 1f95290..ffcbba9 100644 --- a/gcc/config/rs6000/rs6000-p8swap.c +++ b/gcc/config/rs6000/rs6000-p8swap.c @@ -741,6 +741,7 @@ rtx_is_swappable_p (rtx op, unsigned int *special) { default: break; + case UNSPEC_VBPERMQ: case UNSPEC_VMRGH_DIRECT: case UNSPEC_VMRGL_DIRECT: case UNSPEC_VPACK_SIGN_SIGN_SAT: @@ -762,8 +763,14 @@ rtx_is_swappable_p (rtx op, unsigned int *special) case UNSPEC_VSUMSWS: case UNSPEC_VSUMSWS_DIRECT: case UNSPEC_VSX_CONCAT: + case UNSPEC_VSX_CVDPSPN: + case UNSPEC_VSX_CVSPDP: + case UNSPEC_VSX_CVSPDPN: + case UNSPEC_VSX_EXTRACT: case UNSPEC_VSX_SET: case UNSPEC_VSX_SLDWI: + case UNSPEC_VSX_VEC_INIT: + case UNSPEC_VSX_VSLO: case UNSPEC_VUNPACK_HI_SIGN: case UNSPEC_VUNPACK_HI_SIGN_DIRECT: case UNSPEC_VUNPACK_LO_SIGN: @@ -774,12 +781,6 @@ rtx_is_swappable_p (rtx op, unsigned int *special) case UNSPEC_VUPKLPX: case UNSPEC_VUPKLS_V4SF: case UNSPEC_VUPKLU_V4SF: - case UNSPEC_VSX_CVDPSPN: - case UNSPEC_VSX_CVSPDP: - case UNSPEC_VSX_CVSPDPN: - case UNSPEC_VSX_EXTRACT: - case UNSPEC_VSX_VSLO: - case UNSPEC_VSX_VEC_INIT: return 0; case UNSPEC_VSPLT_DIRECT: case UNSPEC_VSX_XXSPLTD: diff --git a/gcc/testsuite/gcc.target/powerpc/swaps-p8-46.c b/gcc/testsuite/gcc.target/powerpc/swaps-p8-46.c new file mode 100644 index 0000000..23494b6 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/swaps-p8-46.c @@ -0,0 +1,34 @@ +/* { dg-do run { target { powerpc64le-*-* } } } */ +/* { dg-require-effective-target powerpc_p8vector_ok } */ +/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power8" } } */ +/* { dg-options "-mcpu=power8 -O2 " } */ + +typedef __attribute__ ((__aligned__ (8))) unsigned long long __m64; +typedef float __m128 __attribute__ ((__vector_size__ (16), __may_alias__)); + +/* PR84033. Extracted from xmmintrin.h but with a pointer param to + allow swaps to happen when not inline. */ +int __attribute__ ((__noinline__)) +_mm_movemask_ps (__m128 *__A) +{ + __vector __m64 result; + static const __vector unsigned int perm_mask = + { + 0x00204060, 0x80808080, 0x80808080, 0x80808080 + }; + + result = (__vector __m64) + __builtin_vec_vbpermq ((__vector unsigned char) (*__A), + (__vector unsigned char) perm_mask); + return result[1]; +} + +int +main (void) +{ + union { unsigned int i[4]; __m128 m; } x + = { 0x80000000, 0x80000000, 0x7fffffff, 0x7fffffff }; + if (_mm_movemask_ps (&x.m) != 3) + __builtin_abort (); + return 0; +}