From patchwork Tue Oct 1 01:24:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Schmidt X-Patchwork-Id: 1169673 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-509932-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="hcTwSaWl"; 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 46j1lP5fJpz9sPJ for ; Tue, 1 Oct 2019 11:24:31 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :reply-to:to:from:subject:message-id:date:mime-version :content-type:content-transfer-encoding; q=dns; s=default; b=xfy f96om/EG4cj53qf7DOvGbjt/ch1S1aLMl9qPFgBhGzVdG3+T1/zOft8xO951/Dlr Xt+ChuG/OIiTack4KyOXTsxwBhTa2GX346m9tcMQgvl7y6sywYfKuhEeii0Ks98U 0hJvRf94ro344W5Vv43Xj/TQKOXuQbSLqUKJENvg= 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 :reply-to:to:from:subject:message-id:date:mime-version :content-type:content-transfer-encoding; s=default; bh=Q0xLV4q/E D4gK9smL8a3bIW9lFc=; b=hcTwSaWlFLtQ5XQVsKUKuxDMOORanyeMyNzbmWus1 XYP1PRL+PUoi2a6Spa1nAMeqVf9pJskE436L3zG6vAp/RJwmatT8HiK9uljsxdzj S+UcRyrymnPfkWQfdt5Ag51KFPTWI5asHONpQ2BsEZi/xmnS4erUq52Fr5nyf4kk 2M= Received: (qmail 69837 invoked by alias); 1 Oct 2019 01:24:23 -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 69785 invoked by uid 89); 1 Oct 2019 01:24:17 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-7.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, HTML_MESSAGE, KAM_NUMSUBJECT, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy=H*c:alternative X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0a-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.156.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 01 Oct 2019 01:24:16 +0000 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x911MZHw102136; Mon, 30 Sep 2019 21:24:12 -0400 Received: from ppma02wdc.us.ibm.com (aa.5b.37a9.ip4.static.sl-reverse.com [169.55.91.170]) by mx0a-001b2d01.pphosted.com with ESMTP id 2vbu67apns-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Sep 2019 21:24:12 -0400 Received: from pps.filterd (ppma02wdc.us.ibm.com [127.0.0.1]) by ppma02wdc.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id x911GTLT003244; Tue, 1 Oct 2019 01:24:11 GMT Received: from b03cxnp08027.gho.boulder.ibm.com (b03cxnp08027.gho.boulder.ibm.com [9.17.130.19]) by ppma02wdc.us.ibm.com with ESMTP id 2v9y57ya8x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 01 Oct 2019 01:24:11 +0000 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x911OAWR58655198 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 1 Oct 2019 01:24:10 GMT Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 68552BE04F; Tue, 1 Oct 2019 01:24:10 +0000 (GMT) Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3858DBE051; Tue, 1 Oct 2019 01:24:10 +0000 (GMT) Received: from Bills-MacBook-Pro.local (unknown [9.211.79.35]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP; Tue, 1 Oct 2019 01:24:10 +0000 (GMT) Reply-To: wschmidt@linux.ibm.com To: GCC Patches , Segher Boessenkool From: Bill Schmidt Subject: [PATCH] rs6000: Fix PR91275 Message-ID: <6569d067-8ebc-8360-61a8-499a3700d216@linux.ibm.com> Date: Mon, 30 Sep 2019 20:24:09 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 Hi, PR91275 observes that __builtin_crypto_vpmsumd fails to work properly with -O1 or higher with -mcpu=power8. That combination spells swap optimization. Indeed, all vpmsum* instructions were being accepted as swappable operations. This is correct for all of them but vpmsumd, which creates a 128-bit result. The -std=gnu11 in the testcase is there to avoid errors about long long not being accepted with pure ANSI. The "11" part is arbitrary. The testcase is modified from the original bug report. This patch disallows swap optimization in the presence of vpmsumd. Bootstrapped and tested on powerpc64le-unknown-linux-gnu. Is this okay for trunk, and for backport to all active branches after an appropriate waiting period? Thanks, Bill [gcc] 2019-09-30 Bill Schmidt * config/rs6000/rs6000-p8swap.c (rtx_is_swappable_p): Don't swap vpmsumd. [gcc/testsuite] 2019-09-30 Bill Schmidt * gcc.target/powerpc/pr91275.c: New. Index: gcc/config/rs6000/rs6000-p8swap.c =================================================================== --- gcc/config/rs6000/rs6000-p8swap.c (revision 276360) +++ gcc/config/rs6000/rs6000-p8swap.c (working copy) @@ -791,6 +791,11 @@ rtx_is_swappable_p (rtx op, unsigned int *special) case UNSPEC_REDUC_PLUS: case UNSPEC_REDUC: return 1; + case UNSPEC_VPMSUM: + /* vpmsumd is not swappable, but vpmsum[bhw] are. */ + if (GET_MODE (op) == V2DImode) + return 0; + break; } } Index: gcc/testsuite/gcc.target/powerpc/pr91275.c =================================================================== --- gcc/testsuite/gcc.target/powerpc/pr91275.c (nonexistent) +++ gcc/testsuite/gcc.target/powerpc/pr91275.c (working copy) @@ -0,0 +1,21 @@ +/* Test that we generate vpmsumd correctly without a swap error. */ + +/* { dg-do run { target { p8vector_hw } } } */ +/* { dg-options "-O2 -std=gnu11" } */ + +#include + +int main() { + + const unsigned long long r0l = 0x8e7dfceac070e3a0; + vector unsigned long long r0 = (vector unsigned long long) {r0l, 0}, v; + const vector unsigned long long pd + = (vector unsigned long) {0xc2LLU << 56, 0}; + + v = __builtin_crypto_vpmsumd ((vector unsigned long long) {r0[0], 0}, pd); + + if (v[0] != 0x4000000000000000 || v[1] != 0x65bd7ab605a4a8ff) + __builtin_abort (); + + return 0; +}