From patchwork Tue Jun 19 18:37:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kelvin Nilsen X-Patchwork-Id: 931798 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-480050-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="AESGRUK1"; 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 419GtR6Lv7z9s37 for ; Wed, 20 Jun 2018 04:38:06 +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:to:cc :from:subject:date:mime-version:content-type :content-transfer-encoding:message-id; q=dns; s=default; b=RXc4a tEPKiDdvXTvm/hdX+RvjJLidLKA8ZIEm4DTLk4zgQnuT3Em51bPnB/sWj5Hg4ndk Ge+Hbl2aUxvdgBkCL/BgivAhjCJGAReas3o8Rlh18Bp/1StUNsb/AuYELNAXT1IU EnFXTJHJsGalTtLjVorWnFKI8108tn3za2swAU= 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:to:cc :from:subject:date:mime-version:content-type :content-transfer-encoding:message-id; s=default; bh=XqoMsdEvXQH IwmXGFWosIIuLYQM=; b=AESGRUK1LS9PNUzNOHoiZFXFvn2vmazB/1Wi19Vf5zM xuM80IdqUFirS1AQm0xYGWU8+b8nV0y0VvpaG6uXNay3793BbdRMWgnjFtSck9VD bgd8ml+/9hQMPEYcwq+u0sFWUSzf/Aa/xyi11v7JWGvhQoE7i91T1kspDWOuVB9Q = Received: (qmail 53247 invoked by alias); 19 Jun 2018 18:37:59 -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 53226 invoked by uid 89); 19 Jun 2018 18:37:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=1112, qualifiers, 2326, differently X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 19 Jun 2018 18:37:56 +0000 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w5JIYMpg082472 for ; Tue, 19 Jun 2018 14:37:55 -0400 Received: from e35.co.us.ibm.com (e35.co.us.ibm.com [32.97.110.153]) by mx0b-001b2d01.pphosted.com with ESMTP id 2jq71grhb4-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 19 Jun 2018 14:37:54 -0400 Received: from localhost by e35.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 19 Jun 2018 12:37:54 -0600 Received: from b03cxnp08026.gho.boulder.ibm.com (9.17.130.18) by e35.co.us.ibm.com (192.168.1.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 19 Jun 2018 12:37:53 -0600 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w5JIbqq01900844 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 19 Jun 2018 11:37:52 -0700 Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 31CF06E054; Tue, 19 Jun 2018 12:37:52 -0600 (MDT) Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E4A3B6E052; Tue, 19 Jun 2018 12:37:51 -0600 (MDT) Received: from kelvins-mbp-2.rchland.ibm.com (unknown [9.10.86.22]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP; Tue, 19 Jun 2018 12:37:51 -0600 (MDT) To: gcc-patches@gcc.gnu.org Cc: segher@gcc.gnu.org From: Kelvin Nilsen Subject: [PATCH v2, rs6000] Fix implementation of vec_pack (vector double, vector double) built-in function Date: Tue, 19 Jun 2018 13:37:51 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18061918-0012-0000-0000-0000167FE93A X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009221; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000265; SDB=6.01049354; UDB=6.00537678; IPR=6.00828327; MB=3.00021743; MTD=3.00000008; XFM=3.00000015; UTC=2018-06-19 18:37:53 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18061918-0013-0000-0000-0000536246EE Message-Id: <46349fd1-088a-c404-f300-19fd6fda50af@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-06-19_10:, , signatures=0 This patch fixes an error in the code generation for vec_pack (vector double, vector double). As previously implemented, this built-in function translates to the vpkudum instruction. This patch causes vec_pack (vector double, vector double) to behave the same as vec_float2 for the same type signature, producing the vmrgow instruction on little-endian targets and the vmrgew instruction on big-endian targets. This revision differs from the initial path submission in that it combines all of the new testing into two test programs, using target qualifiers on the dg scan-assembler-times directives. This patch has bootstrapped and tested without regressions on powerpc64le-unknown-linux (both P8 and P9) and on powerpc-linux (P8 big-endian, both -m32 and -m64). Is this ok for the trunk? gcc/ChangeLog: 2018-06-19 Kelvin Nilsen * config/rs6000/rs6000-c.c (altivec_overloaded_builtins): Change behavior of vec_pack (vector double, vector double) to match behavior of vec_float2 (vector double, vector double). gcc/testsuite/ChangeLog: 2018-06-19 Kelvin Nilsen * gcc.target/powerpc/builtins-3-p8.c (test_pack_float): Remove this test. * gcc.target/powerpc/builtins-9.c: New test. * gcc.target/powerpc/fold-vec-pack-double.c: Modify dg directives to expect different code generation on big-endian vs. little-endian targets. Index: gcc/config/rs6000/rs6000-c.c =================================================================== --- gcc/config/rs6000/rs6000-c.c (revision 261341) +++ gcc/config/rs6000/rs6000-c.c (working copy) @@ -2425,7 +2425,7 @@ const struct altivec_builtin_types altivec_overloa RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, 0 }, { ALTIVEC_BUILTIN_VEC_PACK, P8V_BUILTIN_VPKUDUM, RS6000_BTI_bool_V4SI, RS6000_BTI_bool_V2DI, RS6000_BTI_bool_V2DI, 0 }, - { ALTIVEC_BUILTIN_VEC_PACK, P8V_BUILTIN_VPKUDUM, + { ALTIVEC_BUILTIN_VEC_PACK, P8V_BUILTIN_FLOAT2_V2DF, RS6000_BTI_V4SF, RS6000_BTI_V2DF, RS6000_BTI_V2DF, 0 }, { P8V_BUILTIN_VEC_NEG, P8V_BUILTIN_NEG_V16QI, Index: gcc/testsuite/gcc.target/powerpc/builtins-3-p8.c =================================================================== --- gcc/testsuite/gcc.target/powerpc/builtins-3-p8.c (revision 261341) +++ gcc/testsuite/gcc.target/powerpc/builtins-3-p8.c (working copy) @@ -11,12 +11,6 @@ test_eq_long_long (vector bool long long x, vector return vec_cmpeq (x, y); } -vector float -test_pack_float (vector double x, vector double y) -{ - return vec_pack (x, y); -} - vector unsigned char test_vsi_packs_vusi_vusi (vector unsigned short x, vector unsigned short y) @@ -214,7 +208,6 @@ test_neg_double (vector double x) /* Expected test results: test_eq_long_long 1 vcmpequd inst - test_pack_float 1 vpkudum inst test_vsi_packs_vsll_vsll 1 vpksdss test_vui_packs_vull_vull 1 vpkudus test_vui_packs_vssi_vssi 1 vpkshss @@ -239,7 +232,6 @@ test_neg_double (vector double x) */ /* { dg-final { scan-assembler-times "vcmpequd" 1 } } */ -/* { dg-final { scan-assembler-times "vpkudum" 1 } } */ /* { dg-final { scan-assembler-times "vpksdss" 1 } } */ /* { dg-final { scan-assembler-times "vpkudus" 1 } } */ /* { dg-final { scan-assembler-times "vpkuhus" 2 } } */ Index: gcc/testsuite/gcc.target/powerpc/builtins-9.c =================================================================== --- gcc/testsuite/gcc.target/powerpc/builtins-9.c (nonexistent) +++ gcc/testsuite/gcc.target/powerpc/builtins-9.c (working copy) @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target powerpc_p8vector_ok } */ +/* Expect same instruction selecton on p8 and above. Fix if future + targets behave differently. */ +/* { dg-options "-O3 -maltivec" } */ +/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } } */ + +#include + +vector float +test_pack_float (vector double x, vector double y) +{ + return vec_pack (x, y); +} + +/* { dg-final { scan-assembler-times "vmrgew" 1 { target be } } } */ +/* { dg-final { scan-assembler-times "vmrgow" 1 { target le } } } */ + +/* { dg-final { scan-assembler-times "xvcvdpsp" 2 } } */ +/* { dg-final { scan-assembler-times "xxpermdi" 2 } } */ + Index: gcc/testsuite/gcc.target/powerpc/fold-vec-pack-double.c =================================================================== --- gcc/testsuite/gcc.target/powerpc/fold-vec-pack-double.c (revision 261341) +++ gcc/testsuite/gcc.target/powerpc/fold-vec-pack-double.c (working copy) @@ -3,7 +3,10 @@ /* { dg-do compile } */ /* { dg-require-effective-target powerpc_p8vector_ok } */ -/* { dg-options "-mvsx -mpower8-vector -O2" } */ +/* Expect same instruction selecton on p8 and above. Fix if future + targets behave differently. */ +/* { dg-options "-mvsx -O2" } */ +/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } } */ #include @@ -15,4 +18,5 @@ test_pack (vector double vd2, vector double vd3) return vec_pack (vd2, vd3); } -/* { dg-final { scan-assembler-times "vpkudum" 1 } } */ +/* { dg-final { scan-assembler-times "vmrgew" 1 { target be } } } */ +/* { dg-final { scan-assembler-times "vmrgow" 1 { target le } } } */