From patchwork Sun Nov 25 12:16:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 1002789 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-490830-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="o9LpL9tS"; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="sIYN33kO"; 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 432pv20Rflz9s1c for ; Sun, 25 Nov 2018 23:16:44 +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=YDpott75Ej7d2Z9hy6lx/kQ9YSOOsXfUxvzm7T/WJQweonuZic /77FeL5eEZzmvGqrTRxllbzq0jY8Q+nPkRdVMQFINFFaJiB3yVleaNZ6F2kMX9y9 XHKEQ+tV/zamnFu2PvNul63BFKR8UntbN140azX0zmXBgPjxnfd6uWE9A= 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=gXNN+QNw7n5zScEAEl4OgHpCjgE=; b=o9LpL9tSfCyu5EAZpVIj KG7vIceaGkUEtsV2zgr+fkEga6OmX8pIbSFbJeY7AylF9jLoiokS2sFKnOxAo58b y/lkyHQ5x946zjdCfj9R9LgXJIn3AC0RsnDMe7WhpLmGaBlNa0D0prEwACUYfnIb PfT1Bs6IZfCK+nlY81EkocE= Received: (qmail 62635 invoked by alias); 25 Nov 2018 12:16:37 -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 62200 invoked by uid 89); 25 Nov 2018 12:16:36 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.7 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=voidmode, Consider, VOIDmode, HX-Received:624c X-HELO: mail-pf1-f182.google.com Received: from mail-pf1-f182.google.com (HELO mail-pf1-f182.google.com) (209.85.210.182) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 25 Nov 2018 12:16:34 +0000 Received: by mail-pf1-f182.google.com with SMTP id u3-v6so5235760pfm.4 for ; Sun, 25 Nov 2018 04:16:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=GJ4VAZ2HI4q9ZtZHRpfkEbpBp+slbFHpfN4fdk8o+RE=; b=sIYN33kOHS5bQGLu7Yv0HuqRg8Fzsb7BemT9VbvS5kjLYlGCROKkMvnxTUxc72Q0Tp r8vzqmY5XVjEteapXQCMq9TLtAFxPnc/wAcNJxiz36px2aHT+lQ22wdjZe4ZwtAvXnpT UEUY2UxB8MzJ1BH3jbw30ErIZVMOq1sHa49mqTeyL0hTobirTyB442NPGfohVrLZHCPf /+qzcd4vi2kR/PpDfvgxRB1JYiP7UB5lI0vM0NGdGcSOBmn6BZXREFz5oIwgnBLhxWWo YA18zv/jsMXYRmZmbaguX0Ohq7WayKDs1+QvypBiRk1LrA6ubQ12fF7MsIJnIoTOzjdi RjWg== Received: from bubble.grove.modra.org ([58.175.241.133]) by smtp.gmail.com with ESMTPSA id q8-v6sm115478934pfa.18.2018.11.25.04.16.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 25 Nov 2018 04:16:32 -0800 (PST) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id 7CCE28077C; Sun, 25 Nov 2018 22:46:28 +1030 (ACDT) Date: Sun, 25 Nov 2018 22:46:28 +1030 From: Alan Modra To: gcc-patches@gcc.gnu.org Cc: Segher Boessenkool Subject: [RS6000] CONST_DOUBLE tidy Message-ID: <20181125121628.GM21617@bubble.grove.modra.org> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) X-IsSubscribed: yes Once upon a time CONST_DOUBLE was used to hold large integer constants that didn't fit into a CONST_INT. Now that CONST_INT is always at least 64 bits, and the rs6000 backend uses CONST_WIDE_INT for larger integers, there is no need for old code dealing with integers in CONST_DOUBLE. The rs6000 backend also doesn't create DImode subregs of TFmode CONST_DOUBLE, as once we did. This patch cleans up a few leftovers from the past. Bootstrapped etc. powerpc64le-linux, and powerpc64-linux testing both -m32 and -m64. * config/rs6000/predicates.md (easy_fp_constant): Remove code dealing with integers in const_double. Assert on unexpected modes. * config/rs6000/rs6000.c (rs6000_emit_move): Comment fixes. Don't call easy_fp_constant for Pmode. (rs6000_hash_constant): Remove code dealing with integers in const_double. (rs6000_legitimate_constant_p): Likewise. (output_toc): Formatting, use CONST_DOUBLE_P. diff --git a/gcc/config/rs6000/predicates.md b/gcc/config/rs6000/predicates.md index afe1b286833..9fbeb928fe6 100644 --- a/gcc/config/rs6000/predicates.md +++ b/gcc/config/rs6000/predicates.md @@ -562,12 +562,11 @@ (define_predicate "vsx_reg_or_cint_operand" (define_predicate "easy_fp_constant" (match_code "const_double") { - if (GET_MODE (op) != mode - || (!SCALAR_FLOAT_MODE_P (mode) && mode != DImode)) - return 0; + gcc_assert (GET_MODE (op) == mode + && SCALAR_FLOAT_MODE_P (mode)); /* Consider all constants with -msoft-float to be easy. */ - if (TARGET_SOFT_FLOAT && mode != DImode) + if (TARGET_SOFT_FLOAT) return 1; /* 0.0D is not all zero bits. */ @@ -575,37 +574,15 @@ (define_predicate "easy_fp_constant" return 0; /* The constant 0.0 is easy under VSX. */ - if (TARGET_VSX && SCALAR_FLOAT_MODE_P (mode) && op == CONST0_RTX (mode)) + if (TARGET_VSX && op == CONST0_RTX (mode)) return 1; - /* If we are using V.4 style PIC, consider all constants to be hard. */ - if (flag_pic && DEFAULT_ABI == ABI_V4) - return 0; - - /* If we have real FPRs, consider floating point constants hard (other than - 0.0 under VSX), so that the constant gets pushed to memory during the - early RTL phases. This has the advantage that double precision constants - that can be represented in single precision without a loss of precision - will use single precision loads. */ - - switch (mode) - { - case E_KFmode: - case E_IFmode: - case E_TFmode: - case E_DFmode: - case E_SFmode: - return 0; - - case E_DImode: - return (num_insns_constant (op, DImode) <= 2); - - case E_SImode: - return 1; - - default: - gcc_unreachable (); - } + /* Otherwise consider floating point constants hard, so that the + constant gets pushed to memory during the early RTL phases. This + has the advantage that double precision constants that can be + represented in single precision without a loss of precision will + use single precision loads. */ + return 0; }) ;; Return 1 if the operand is a constant that can loaded with a XXSPLTIB diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 479dae547fa..42dcb61904c 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -9883,13 +9883,10 @@ rs6000_emit_move (rtx dest, rtx source, machine_mode mode) debug_rtx (source); } - /* Sanity checks. Check that we get CONST_DOUBLE only when we should. */ + /* Check that we get CONST_WIDE_INT only when we should. */ if (CONST_WIDE_INT_P (operands[1]) && GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT) - { - /* This should be fixed with the introduction of CONST_WIDE_INT. */ - gcc_unreachable (); - } + gcc_unreachable (); #ifdef HAVE_AS_GNU_ATTRIBUTE /* If we use a long double type, set the flags in .gnu_attribute that say @@ -10228,13 +10225,11 @@ rs6000_emit_move (rtx dest, rtx source, machine_mode mode) else if (mode == Pmode && CONSTANT_P (operands[1]) && GET_CODE (operands[1]) != HIGH - && ((GET_CODE (operands[1]) != CONST_INT - && ! easy_fp_constant (operands[1], mode)) - || (GET_CODE (operands[1]) == CONST_INT - && (num_insns_constant (operands[1], mode) - > (TARGET_CMODEL != CMODEL_SMALL ? 3 : 2))) - || (GET_CODE (operands[0]) == REG - && FP_REGNO_P (REGNO (operands[0])))) + && ((REG_P (operands[0]) + && FP_REGNO_P (REGNO (operands[0]))) + || !CONST_INT_P (operands[1]) + || (num_insns_constant (operands[1], mode) + > (TARGET_CMODEL != CMODEL_SMALL ? 3 : 2))) && !toc_relative_expr_p (operands[1], false, NULL, NULL) && (TARGET_CMODEL == CMODEL_SMALL || can_create_pseudo_p () @@ -29430,10 +29425,7 @@ rs6000_hash_constant (rtx k) } case CONST_DOUBLE: - if (mode != VOIDmode) - return real_hash (CONST_DOUBLE_REAL_VALUE (k)) * result; - flen = 2; - break; + return real_hash (CONST_DOUBLE_REAL_VALUE (k)) * result; case CODE_LABEL: fidx = 3; @@ -29638,9 +29630,9 @@ output_toc (FILE *file, rtx x, int labelno, machine_mode mode) /* Handle FP constants specially. Note that if we have a minimal TOC, things we put here aren't actually in the TOC, so we can allow FP constants. */ - if (GET_CODE (x) == CONST_DOUBLE && - (GET_MODE (x) == TFmode || GET_MODE (x) == TDmode - || GET_MODE (x) == IFmode || GET_MODE (x) == KFmode)) + if (CONST_DOUBLE_P (x) + && (GET_MODE (x) == TFmode || GET_MODE (x) == TDmode + || GET_MODE (x) == IFmode || GET_MODE (x) == KFmode)) { long k[4]; @@ -29678,8 +29670,8 @@ output_toc (FILE *file, rtx x, int labelno, machine_mode mode) return; } } - else if (GET_CODE (x) == CONST_DOUBLE && - (GET_MODE (x) == DFmode || GET_MODE (x) == DDmode)) + else if (CONST_DOUBLE_P (x) + && (GET_MODE (x) == DFmode || GET_MODE (x) == DDmode)) { long k[2]; @@ -29712,8 +29704,8 @@ output_toc (FILE *file, rtx x, int labelno, machine_mode mode) return; } } - else if (GET_CODE (x) == CONST_DOUBLE && - (GET_MODE (x) == SFmode || GET_MODE (x) == SDmode)) + else if (CONST_DOUBLE_P (x) + && (GET_MODE (x) == SFmode || GET_MODE (x) == SDmode)) { long l; @@ -37615,11 +37607,13 @@ rs6000_legitimate_constant_p (machine_mode mode, rtx x) if (TARGET_ELF && tls_referenced_p (x)) return false; - return ((GET_CODE (x) != CONST_DOUBLE && GET_CODE (x) != CONST_VECTOR) - || GET_MODE (x) == VOIDmode - || (TARGET_POWERPC64 && mode == DImode) - || easy_fp_constant (x, mode) - || easy_vector_constant (x, mode)); + if (CONST_DOUBLE_P (x)) + return easy_fp_constant (x, mode); + + if (GET_CODE (x) == CONST_VECTOR) + return easy_vector_constant (x, mode); + + return true; }