From patchwork Wed Mar 21 15:42:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Meissner X-Patchwork-Id: 888922 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-475169-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="FzRIw1io"; 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 405vF53j4Kz9s0q for ; Thu, 22 Mar 2018 02:42:17 +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:subject:mime-version:content-type:message-id; q=dns; s= default; b=DKTpDk88xhBVVQ4Zn1fmp0JJL0UO41Wrnun192M5gZ3dWeH1tb+RZ iUEdBQRjT8P3s/+I7jdcPpENP2h0bXN+iplCOuSDDdpHYBag+JU5hZsDlaipGMtD UnbcU0NsoVg2MdXxHIA3K2t+FsDnFarTywP2wPngVMLYh7XkGqelyU= 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:subject:mime-version:content-type:message-id; s= default; bh=8S/WRctO1UY1481sF1quJ58ZbqI=; b=FzRIw1ioD3VAQOlRmJiF 1NJ4TUw7W66kTHZtaM82/+RqXBIvsfSdFlapH8rWuWhRWYh92Y9nEzfYE8AvbTfm F/qR6RGeOPxoqZ3F4CCc09WKvi/q293THu56fnDJ+RoWZ5H0wBItIWJKkg3wu+jK IyqjUTMy4zFIvljyhDoH86s= Received: (qmail 109659 invoked by alias); 21 Mar 2018 15:42:10 -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 109647 invoked by uid 89); 21 Mar 2018 15:42:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=H*Ad:U*wschmidt, powerpc64***, powerpc64*-*-* 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; Wed, 21 Mar 2018 15:42:07 +0000 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w2LFeX8p083414 for ; Wed, 21 Mar 2018 11:42:05 -0400 Received: from e16.ny.us.ibm.com (e16.ny.us.ibm.com [129.33.205.206]) by mx0b-001b2d01.pphosted.com with ESMTP id 2gurdsnxgw-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Wed, 21 Mar 2018 11:42:05 -0400 Received: from localhost by e16.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 21 Mar 2018 11:42:04 -0400 Received: from b01cxnp22036.gho.pok.ibm.com (9.57.198.26) by e16.ny.us.ibm.com (146.89.104.203) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 21 Mar 2018 11:42:02 -0400 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w2LFg2sf57671706; Wed, 21 Mar 2018 15:42:02 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E0A2BAE043; Wed, 21 Mar 2018 11:43:35 -0400 (EDT) Received: from ibm-tiger.the-meissners.org (unknown [9.32.77.111]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTP id C5D05AE034; Wed, 21 Mar 2018 11:43:35 -0400 (EDT) Received: by ibm-tiger.the-meissners.org (Postfix, from userid 500) id C1F8349952; Wed, 21 Mar 2018 11:42:01 -0400 (EDT) Date: Wed, 21 Mar 2018 11:42:01 -0400 From: Michael Meissner To: GCC Patches , Segher Boessenkool , David Edelsohn , Bill Schmidt Subject: [PATCH], PR target/84914, Fix complex long double multiply/divide on PowerPC -mabi=ieeelongdouble Mail-Followup-To: Michael Meissner , GCC Patches , Segher Boessenkool , David Edelsohn , Bill Schmidt MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) X-TM-AS-GCONF: 00 x-cbid: 18032115-0024-0000-0000-00000339E985 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008716; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000254; SDB=6.01006329; UDB=6.00512392; IPR=6.00785612; MB=3.00020164; MTD=3.00000008; XFM=3.00000015; UTC=2018-03-21 15:42:04 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18032115-0025-0000-0000-00004765FA2B Message-Id: <20180321154201.GA13408@ibm-tiger.the-meissners.org> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-21_07:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1803210184 X-IsSubscribed: yes Joseph Myers pointed out that we call the wrong function for complex long double multiply and divide. This patch changes the functions called from __multc3/__divtc3 to __mulkc3/__divkc3. I have built this on power8 systems, both a little endian system, and a big endian system using --with-cpu=power8. Both compilers built without error, and had no regressions in the test suite. Can I check this into the trunk? [gcc] 2018-03-21 Michael Meissner PR target/84914 * config/rs6000/rs6000.c (create_complex_muldiv): New helper function to create the function decl for complex long double multiply and divide for -mabi=ieeelongdouble. (init_float128_ieee): Call it. [gcc/testsuite] 2018-03-21 Michael Meissner PR target/84914 * gcc.target/powerpc/mulkc-2.c: New tests to make sure complex long double multiply/divide uses the correct function. * gcc.target/powerpc/mulkc-3.c: Likewise. * gcc.target/powerpc/divkc-2.c: Likewise. * gcc.target/powerpc/divkc-3.c: Likewise. Index: gcc/config/rs6000/rs6000.c =================================================================== --- gcc/config/rs6000/rs6000.c (revision 258601) +++ gcc/config/rs6000/rs6000.c (working copy) @@ -18678,6 +18678,27 @@ init_float128_ibm (machine_mode mode) } } +/* Create a decl for either complex long double multiply or complex long double + divide when long double is IEEE 128-bit floating point. We can't use + __multc3 and __divtc3 because the original long double using IBM extended + double used those names. The complex multiply/divide functions are encoded + as builtin functions with a complex result and 4 scalar inputs. */ + +static void +create_complex_muldiv (const char *name, built_in_function fncode, tree fntype) +{ + tree fndecl = add_builtin_function (name, fntype, fncode, BUILT_IN_NORMAL, + name, NULL_TREE); + + set_builtin_decl (fncode, fndecl, true); + + if (TARGET_DEBUG_BUILTIN) + fprintf (stderr, "create complex %s, fncode: %d, fndecl: 0x%lx\n", name, + (int) fncode, (unsigned long)fndecl); + + return; +} + /* Set up IEEE 128-bit floating point routines. Use different names if the arguments can be passed in a vector register. The historical PowerPC implementation of IEEE 128-bit floating point used _q_ for the names, so @@ -18689,6 +18710,24 @@ init_float128_ieee (machine_mode mode) { if (FLOAT128_VECTOR_P (mode)) { + /* Set up to call __mulkc3 and __divkc3 under -mabi=ieeelongdouble. */ + if (mode == TFmode && TARGET_IEEEQUAD) + { + built_in_function fncode_mul = + (built_in_function)(BUILT_IN_COMPLEX_MUL_MIN + TCmode - MIN_MODE_COMPLEX_FLOAT); + built_in_function fncode_div = + (built_in_function)(BUILT_IN_COMPLEX_DIV_MIN + TCmode - MIN_MODE_COMPLEX_FLOAT); + tree fntype = build_function_type_list (complex_long_double_type_node, + long_double_type_node, + long_double_type_node, + long_double_type_node, + long_double_type_node, + NULL_TREE); + + create_complex_muldiv ("__mulkc3", fncode_mul, fntype); + create_complex_muldiv ("__divkc3", fncode_div, fntype); + } + set_optab_libfunc (add_optab, mode, "__addkf3"); set_optab_libfunc (sub_optab, mode, "__subkf3"); set_optab_libfunc (neg_optab, mode, "__negkf2"); Index: gcc/testsuite/gcc.target/powerpc/mulkc3-3.c =================================================================== --- gcc/testsuite/gcc.target/powerpc/mulkc3-3.c (revision 0) +++ gcc/testsuite/gcc.target/powerpc/mulkc3-3.c (revision 0) @@ -0,0 +1,16 @@ +/* { dg-do compile { target { powerpc64*-*-* } } } */ +/* { dg-require-effective-target powerpc_p9vector_ok } */ +/* { dg-options "-O2 -mpower8-vector -mabi=ibmlongdouble -Wno-psabi" } */ + +/* Check that complex multiply generates the right call when long double is + IBM extended double floating point. */ + +typedef _Complex long double cld_t; + +void +multiply (cld_t *p, cld_t *q, cld_t *r) +{ + *p = *q * *r; +} + +/* { dg-final { scan-assembler "bl __multc3" } } */ Index: gcc/testsuite/gcc.target/powerpc/divkc3-3.c =================================================================== --- gcc/testsuite/gcc.target/powerpc/divkc3-3.c (revision 0) +++ gcc/testsuite/gcc.target/powerpc/divkc3-3.c (revision 0) @@ -0,0 +1,16 @@ +/* { dg-do compile { target { powerpc64*-*-* } } } */ +/* { dg-require-effective-target powerpc_p9vector_ok } */ +/* { dg-options "-O2 -mpower8-vector -mabi=ibmlongdouble -Wno-psabi" } */ + +/* Check that complex multiply generates the right call when long double is + IBM extended double floating point. */ + +typedef _Complex long double cld_t; + +void +divide (cld_t *p, cld_t *q, cld_t *r) +{ + *p = *q / *r; +} + +/* { dg-final { scan-assembler "bl __divtc3" } } */ Index: gcc/testsuite/gcc.target/powerpc/mulkc3-2.c =================================================================== --- gcc/testsuite/gcc.target/powerpc/mulkc3-2.c (revision 0) +++ gcc/testsuite/gcc.target/powerpc/mulkc3-2.c (revision 0) @@ -0,0 +1,16 @@ +/* { dg-do compile { target { powerpc64*-*-* } } } */ +/* { dg-require-effective-target powerpc_p9vector_ok } */ +/* { dg-options "-O2 -mpower8-vector -mabi=ieeelongdouble -Wno-psabi" } */ + +/* Check that complex multiply generates the right call when long double is + IEEE 128-bit floating point. */ + +typedef _Complex long double cld_t; + +void +multiply (cld_t *p, cld_t *q, cld_t *r) +{ + *p = *q * *r; +} + +/* { dg-final { scan-assembler "bl __mulkc3" } } */ Index: gcc/testsuite/gcc.target/powerpc/divkc3-2.c =================================================================== --- gcc/testsuite/gcc.target/powerpc/divkc3-2.c (revision 0) +++ gcc/testsuite/gcc.target/powerpc/divkc3-2.c (revision 0) @@ -0,0 +1,16 @@ +/* { dg-do compile { target { powerpc64*-*-* } } } */ +/* { dg-require-effective-target powerpc_p9vector_ok } */ +/* { dg-options "-O2 -mpower8-vector -mabi=ieeelongdouble -Wno-psabi" } */ + +/* Check that complex multiply generates the right call when long double is + IEEE 128-bit floating point. */ + +typedef _Complex long double cld_t; + +void +divide (cld_t *p, cld_t *q, cld_t *r) +{ + *p = *q / *r; +} + +/* { dg-final { scan-assembler "bl __divkc3" } } */