From patchwork Wed Jun 27 20:26:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Bergner X-Patchwork-Id: 935689 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-480590-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="bwysYsX8"; 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 41GDwQ17s9z9s0w for ; Thu, 28 Jun 2018 06:27:01 +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=Mo3zR ACDiny8hhC4O1P0CmQK1ub0nwphGD/C/CBXZsc7FLmujf7IczfeaaxspizWB6ht0 rG0BP7jmjCyrTSgtn1uELcqgTOai0/p+EQMY0SV8g+89YwKnd43QBc7FPeHHhSn9 WsbLSt4thkCLHocp8fNTT4xMnxUID+DsbPBOYw= 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=qiqLykVdT5o Ali09xSzCDCOlUmg=; b=bwysYsX8e+AEAkrqqyxsOslJHoExTGJFyJscYIa0hYn E81QbjCiLmR+inTAlkyCw04FZeD8cd0JcawNJlc2eQiUMlFxBrlv1cdEUfrs73eK SLoEcb1wVnXB+xfEe5716yx6CNgeZHbDd38xhVRWHDqjb91pt3H8OOJpYqOQXjVc = Received: (qmail 49057 invoked by alias); 27 Jun 2018 20:26:53 -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 48102 invoked by uid 89); 27 Jun 2018 20:26:53 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.8 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=rs6000, 262159, rs6000c, rs6000.c 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; Wed, 27 Jun 2018 20:26:51 +0000 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w5RKMTVZ087147 for ; Wed, 27 Jun 2018 16:26:49 -0400 Received: from e36.co.us.ibm.com (e36.co.us.ibm.com [32.97.110.154]) by mx0a-001b2d01.pphosted.com with ESMTP id 2jvhjd85dh-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 27 Jun 2018 16:26:49 -0400 Received: from localhost by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 27 Jun 2018 14:26:48 -0600 Received: from b03cxnp08028.gho.boulder.ibm.com (9.17.130.20) by e36.co.us.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 27 Jun 2018 14:26:45 -0600 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w5RKQifZ11076006 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 27 Jun 2018 13:26:44 -0700 Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0FAA06A04F; Wed, 27 Jun 2018 14:26:44 -0600 (MDT) Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0E8296A04D; Wed, 27 Jun 2018 14:26:42 -0600 (MDT) Received: from otta.local (unknown [9.80.193.75]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP; Wed, 27 Jun 2018 14:26:42 -0600 (MDT) To: Segher Boessenkool , Joseph Myers Cc: Jonathan Wakely , Bill Schmidt , Michael Meissner , GCC Patches From: Peter Bergner Subject: [PATCH, rs6000, C/C++] Fix PR target/86324: divkc3-1.c FAILs when compiling with -mabi=ieeelongdouble Date: Wed, 27 Jun 2018 15:26:42 -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-cbid: 18062720-0020-0000-0000-00000E368471 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009265; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01053214; UDB=6.00539996; IPR=6.00831138; MB=3.00021889; MTD=3.00000008; XFM=3.00000015; UTC=2018-06-27 20:26:47 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18062720-0021-0000-0000-00006216799D Message-Id: X-IsSubscribed: yes The test case in PR86324 exposes a problem when long double is the same as __ieee128 and we attempt to use the KC mode attribute. A complimentary problem exists when long double is the same as __ibm128 and we try to use the IC mode attribute. The problem is that for the type that long double is set to, we always use internally the long double type and TFmode/TCmode rather than __ieee128/K[FC]mode or __ibm128/I[FC]mode, so we have problems when looking up the unused modes during attribute processing. Talking with Joseph offline, he suggested to add a hook that allows the target to translate mode attributes like the above into the mode that should be used. The patch below implements that suggestion and it fixes the problem test cases. This passed bootstrap and regtesting with no regressions on powerpc64le-linux. Ok for trunk? This is also broken in GCC 8, is this ok to backport once it has has baked on trunk for a few days and assuming testing comes out clean? The pr86324-2.c test case is also broken in GCC 7, but it looks like that has been broken forever, so I'm not sure I'm inclined to want to backport this that far. Thoughts? Peter gcc/ PR target/86324 * target.def (translate_mode_attribute): New hook. * targhooks.h (default_translate_mode_attribute): Declare. * targhooks.c (default_translate_mode_attribute): New function. * doc/tm.texi.in (TARGET_TRANSLATE_MODE_ATTRIBUTE): New hook. * doc/tm.texi: Regenerate. * config/rs6000/rs6000.c (TARGET_TRANSLATE_MODE_ATTRIBUTE): Define. (rs6000_translate_mode_attribute): New function. gcc/c-family/ PR target/86324 * c-attribs.c (handle_mode_attribute): Call new translate_mode_attribute target hook. Index: gcc/target.def =================================================================== --- gcc/target.def (revision 262159) +++ gcc/target.def (working copy) @@ -3310,6 +3310,16 @@ constants can be done inline. The funct HOST_WIDE_INT, (const_tree constant, HOST_WIDE_INT basic_align), default_constant_alignment) +DEFHOOK +(translate_mode_attribute, + "Define this hook if the port should translate machine_mode @var{mode}\n\ +to another mode. For example, rs6000's @code{KFmode}, when it is the same\n\ +as @code{TFmode}.\n\ +\n\ +The default version of the hook returns that mode that was passed in.", + machine_mode, (machine_mode mode), + default_translate_mode_attribute) + /* True if MODE is valid for the target. By "valid", we mean able to be manipulated in non-trivial ways. In particular, this means all the arithmetic is supported. */ Index: gcc/targhooks.c =================================================================== --- gcc/targhooks.c (revision 262159) +++ gcc/targhooks.c (working copy) @@ -393,6 +393,14 @@ default_mangle_assembler_name (const cha return get_identifier (stripped); } +/* The default implementation of TARGET_TRANSLATE_MODE_ATTRIBUTE. */ + +machine_mode +default_translate_mode_attribute (machine_mode mode) +{ + return mode; +} + /* True if MODE is valid for the target. By "valid", we mean able to be manipulated in non-trivial ways. In particular, this means all the arithmetic is supported. Index: gcc/targhooks.h =================================================================== --- gcc/targhooks.h (revision 262159) +++ gcc/targhooks.h (working copy) @@ -72,6 +72,7 @@ extern void default_print_operand_addres extern bool default_print_operand_punct_valid_p (unsigned char); extern tree default_mangle_assembler_name (const char *); +extern machine_mode default_translate_mode_attribute (machine_mode); extern bool default_scalar_mode_supported_p (scalar_mode); extern bool default_libgcc_floating_mode_supported_p (scalar_float_mode); extern opt_scalar_float_mode default_floatn_mode (int, bool); Index: gcc/doc/tm.texi =================================================================== --- gcc/doc/tm.texi (revision 262159) +++ gcc/doc/tm.texi (working copy) @@ -4255,6 +4255,14 @@ hook returns true for both @code{ptr_mod Define this to return nonzero if the memory reference @var{ref} may alias with the system C library errno location. The default version of this hook assumes the system C library errno location is either a declaration of type int or accessed by dereferencing a pointer to int. @end deftypefn +@deftypefn {Target Hook} machine_mode TARGET_TRANSLATE_MODE_ATTRIBUTE (machine_mode @var{mode}) +Define this hook if the port should translate machine_mode @var{mode} +to another mode. For example, rs6000's @code{KFmode}, when it is the same +as @code{TFmode}. + +The default version of the hook returns that mode that was passed in. +@end deftypefn + @deftypefn {Target Hook} bool TARGET_SCALAR_MODE_SUPPORTED_P (scalar_mode @var{mode}) Define this to return nonzero if the port is prepared to handle insns involving scalar mode @var{mode}. For a scalar mode to be Index: gcc/doc/tm.texi.in =================================================================== --- gcc/doc/tm.texi.in (revision 262159) +++ gcc/doc/tm.texi.in (working copy) @@ -3336,6 +3336,8 @@ stack. @hook TARGET_REF_MAY_ALIAS_ERRNO +@hook TARGET_TRANSLATE_MODE_ATTRIBUTE + @hook TARGET_SCALAR_MODE_SUPPORTED_P @hook TARGET_VECTOR_MODE_SUPPORTED_P Index: gcc/config/rs6000/rs6000.c =================================================================== --- gcc/config/rs6000/rs6000.c (revision 262159) +++ gcc/config/rs6000/rs6000.c (working copy) @@ -1802,6 +1802,9 @@ static const struct attribute_spec rs600 #undef TARGET_EH_RETURN_FILTER_MODE #define TARGET_EH_RETURN_FILTER_MODE rs6000_eh_return_filter_mode +#undef TARGET_TRANSLATE_MODE_ATTRIBUTE +#define TARGET_TRANSLATE_MODE_ATTRIBUTE rs6000_translate_mode_attribute + #undef TARGET_SCALAR_MODE_SUPPORTED_P #define TARGET_SCALAR_MODE_SUPPORTED_P rs6000_scalar_mode_supported_p @@ -35677,6 +35680,18 @@ rs6000_eh_return_filter_mode (void) return TARGET_32BIT ? SImode : word_mode; } +/* Target hook for translate_mode_attribute. */ +static machine_mode +rs6000_translate_mode_attribute (machine_mode mode) +{ + if ((FLOAT128_IEEE_P (mode) + && ieee128_float_type_node == long_double_type_node) + || (FLOAT128_IBM_P (mode) + && ibm128_float_type_node == long_double_type_node)) + return COMPLEX_MODE_P (mode) ? E_TCmode : E_TFmode; + return mode; +} + /* Target hook for scalar_mode_supported_p. */ static bool rs6000_scalar_mode_supported_p (scalar_mode mode) Index: gcc/c-family/c-attribs.c =================================================================== --- gcc/c-family/c-attribs.c (revision 262159) +++ gcc/c-family/c-attribs.c (working copy) @@ -1517,6 +1517,10 @@ handle_mode_attribute (tree *node, tree return NULL_TREE; } + /* Allow the target a chance to translate MODE into something supported. + See PR86324. */ + mode = targetm.translate_mode_attribute (mode); + valid_mode = false; switch (GET_MODE_CLASS (mode)) {