From patchwork Thu Mar 24 11:01:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 601541 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3qW3Qt39x2z9sC3 for ; Thu, 24 Mar 2016 22:01:40 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=EDnR2yTM; dkim-atps=neutral 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=hdKI51J0PvT1lCTRaevdgtdrKtsMGVmod87C78bAAHj/mOwkOJ 2V98s+M2Yj1fX4aWmq019LnXtTsy8i81Xie8WEcPw2Xl8yFxomcFbB20SnjE7Mfl kHylbrFLmM4aawhzo9huFGvDVEh1ki44J7501cXwA+eaZ2j9VbzbkG3yQ= 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=d4sTK2lBQt6xrttSG9ByUd7EV8o=; b=EDnR2yTMPtE/HFSMfko2 BoamtRYScE9imtlNkEYTr+ZUnHVMOJ6o1md8DmyeudxfiG3MO2zIoDNTbnjT5Ahu KnM9ae7PUGbB5Nhsff7HOzR1xiBP92vIY1IiyISyK3Yp+6/x3z2FuqvYE1wh1nWk JvFQXiOZ8sPOpW9NfbYKHxQ= Received: (qmail 78338 invoked by alias); 24 Mar 2016 11:01:31 -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 78324 invoked by uid 89); 24 Mar 2016 11:01:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=usual, substituted, nasty, jj X-HELO: mail-pf0-f172.google.com Received: from mail-pf0-f172.google.com (HELO mail-pf0-f172.google.com) (209.85.192.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 24 Mar 2016 11:01:20 +0000 Received: by mail-pf0-f172.google.com with SMTP id u190so54664002pfb.3 for ; Thu, 24 Mar 2016 04:01:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=cDNCwa32U3hc26TtiUlHV5TS5hb8nLydGQTySqhib7w=; b=EqhcSkSqdrMs2p8BBOrUre9k0VpRG6SUEMFmOIdzY7inmTYopc0NRinY41PZmyKB8s dio1uzxJW7H2gtLnApETUr/UYZYCFvqZR83Bdu2cftg2g2NRQRzwXaTVgWc9UFg1UKqP 0dt6B75l6N4np5f2d5xZYA0aqrZIYaUVSi7+gWCzgJEIo5MHzfOzQVIXTQXfPIHeiII+ JpHLyFgDRL3/i3VxVLFfW8zuojR9WjZMvSnQSbSP3jiByXQJ/+0eF2p3fEt88xauLyU4 mdaAGdTV/Y/YTxlMsKz7weiUcUfHGChhOVqwaD6i43dzCF6CdcfqUnTpc53kOQC03u6V 6Oxg== X-Gm-Message-State: AD7BkJLLMqg0Xq1l+of7EMc90SlyNl9YSW72lQuF9MZamaYn2+nYPodzuwo6XHbtQ+rvlg== X-Received: by 10.98.87.5 with SMTP id l5mr11568326pfb.7.1458817278356; Thu, 24 Mar 2016 04:01:18 -0700 (PDT) Received: from bubble.grove.modra.org (CPE-58-160-146-233.sa.bigpond.net.au. [58.160.146.233]) by smtp.gmail.com with ESMTPSA id q85sm9669743pfq.81.2016.03.24.04.01.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Mar 2016 04:01:17 -0700 (PDT) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id 8B50EEA0157; Thu, 24 Mar 2016 21:31:13 +1030 (ACDT) Date: Thu, 24 Mar 2016 21:31:13 +1030 From: Alan Modra To: gcc-patches@gcc.gnu.org Cc: David Edelsohn Subject: [RS6000, PATCH] PR70052, ICE compiling _Decimal128 test case Message-ID: <20160324110113.GE31470@bubble.grove.modra.org> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes This fixes the PR70052 ICE by modifying easy_fp_constant to correctly return false for decimal floating point zero. 0.0D is not an all-zero bit pattern, at least, not the canonical form. I've also taken on Mike's suggestion of using a mode dependent constraint for insns that currently use "j". Note that "easy_fp_constant" is already part of "input_operand" so in the usual case we ought to be prevented from generating 0.0D immediate constants. However, in the past I've seen reload do some nasty tricks when pseudos don't get hard regs, and believe that a pseudo that is known to be equal to 0.0D may have the constant substituted with only constraints being checked, not the operand predicates. So either the "j" constraint needs fixing to reject decimal float (as I had in my original patch) or not used with decimal float (Mike's approach). I left in a small tidy for "j" from my original patch. Bootstrapped and regression tested powerpc64le-linux. OK to apply? gcc/ PR target/70052 * config/rs6000/constraints.md (j): Simplify. * config/rs6000/predicates.md (easy_fp_constant): Exclude decimal float 0.D. * config/rs6000/rs6000.md (zero_fp): New mode_attr. Use in place of "j" in all constraints. (movtd_64bit_nodm): Delete "j" constraint alternative. gcc/testsuite/ * gcc.dg/dfp/pr70052.c: New. diff --git a/gcc/config/rs6000/constraints.md b/gcc/config/rs6000/constraints.md index 9eca757..ea15764 100644 --- a/gcc/config/rs6000/constraints.md +++ b/gcc/config/rs6000/constraints.md @@ -272,4 +272,4 @@ usually better to use @samp{m} or @samp{es} in @code{asm} statements)" (define_constraint "j" "Zero vector constant" - (match_test "op == const0_rtx || op == CONST0_RTX (GET_MODE (op))")) + (match_test "op == const0_rtx || op == CONST0_RTX (mode)")) diff --git a/gcc/config/rs6000/predicates.md b/gcc/config/rs6000/predicates.md index 072291e..71fac76 100644 --- a/gcc/config/rs6000/predicates.md +++ b/gcc/config/rs6000/predicates.md @@ -527,13 +527,14 @@ && mode != DImode) return 1; + /* 0.0D is not all zero bits. */ + if (DECIMAL_FLOAT_MODE_P (mode)) + return 0; + /* The constant 0.0 is easy under VSX. */ if (TARGET_VSX && SCALAR_FLOAT_MODE_P (mode) && op == CONST0_RTX (mode)) return 1; - if (DECIMAL_FLOAT_MODE_P (mode)) - return 0; - /* If we are using V.4 style PIC, consider all constants to be hard. */ if (flag_pic && DEFAULT_ABI == ABI_V4) return 0; diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index d4678af..d47f93e 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -428,6 +428,16 @@ (SD "REAL_VALUE_TO_TARGET_DECIMAL32") (DD "REAL_VALUE_TO_TARGET_DECIMAL64")]) +; Whether 0.0 has an all-zero bit pattern +(define_mode_attr zero_fp [(SF "j") + (DF "j") + (TF "j") + (IF "j") + (KF "j") + (SD "wn") + (DD "wn") + (TD "wn")]) + ; Definitions for load to 32-bit fpr register (define_mode_attr f32_lr [(SF "f") (SD "wz")]) (define_mode_attr f32_lr2 [(SF "wb") (SD "wn")]) @@ -6472,7 +6482,7 @@ (define_insn "mov_hardfloat" [(set (match_operand:FMOVE32 0 "nonimmediate_operand" "=!r,!r,m,f,,,!r,,,,,,Z,?,?r,*c*l,!r,*h") - (match_operand:FMOVE32 1 "input_operand" "r,m,r,f,,j,j,,,,,Z,,r,,r,h,0"))] + (match_operand:FMOVE32 1 "input_operand" "r,m,r,f,,,,,,,,Z,,r,,r,h,0"))] "(gpc_reg_operand (operands[0], mode) || gpc_reg_operand (operands[1], mode)) && (TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT)" @@ -6612,7 +6622,7 @@ (define_insn "*mov_hardfloat32" [(set (match_operand:FMOVE64 0 "nonimmediate_operand" "=m,d,d,,Z,,o,,,!r,Y,r,!r") - (match_operand:FMOVE64 1 "input_operand" "d,m,d,Z,,o,,,j,j,r,Y,r"))] + (match_operand:FMOVE64 1 "input_operand" "d,m,d,Z,,o,,,,,r,Y,r"))] "! TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT && (gpc_reg_operand (operands[0], mode) || gpc_reg_operand (operands[1], mode))" @@ -6650,7 +6660,7 @@ ; List Y->r and r->Y before r->r for reload. (define_insn "*mov_hardfloat64" [(set (match_operand:FMOVE64 0 "nonimmediate_operand" "=m,d,d,,o,,Z,,,!r,Y,r,!r,*c*l,!r,*h,r,wg,r,") - (match_operand:FMOVE64 1 "input_operand" "d,m,d,o,,Z,,,j,j,r,Y,r,r,h,0,wg,r,,r"))] + (match_operand:FMOVE64 1 "input_operand" "d,m,d,o,,Z,,,,,r,Y,r,r,h,0,wg,r,,r"))] "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT && (gpc_reg_operand (operands[0], mode) || gpc_reg_operand (operands[1], mode))" @@ -6713,7 +6723,7 @@ (define_insn_and_split "*mov_64bit_dm" [(set (match_operand:FMOVE128_FPR 0 "nonimmediate_operand" "=m,d,d,d,Y,r,r,r,wh") - (match_operand:FMOVE128_FPR 1 "input_operand" "d,m,d,j,r,jY,r,wh,r"))] + (match_operand:FMOVE128_FPR 1 "input_operand" "d,m,d,,r,jY,r,wh,r"))] "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_POWERPC64 && FLOAT128_2REG_P (mode) && (mode != TDmode || WORDS_BIG_ENDIAN) @@ -6726,8 +6736,8 @@ [(set_attr "length" "8,8,8,8,12,12,8,8,8")]) (define_insn_and_split "*movtd_64bit_nodm" - [(set (match_operand:TD 0 "nonimmediate_operand" "=m,d,d,d,Y,r,r") - (match_operand:TD 1 "input_operand" "d,m,d,j,r,jY,r"))] + [(set (match_operand:TD 0 "nonimmediate_operand" "=m,d,d,Y,r,r") + (match_operand:TD 1 "input_operand" "d,m,d,r,jY,r"))] "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_POWERPC64 && !WORDS_BIG_ENDIAN && (gpc_reg_operand (operands[0], TDmode) || gpc_reg_operand (operands[1], TDmode))" @@ -6735,11 +6745,11 @@ "&& reload_completed" [(pc)] { rs6000_split_multireg_move (operands[0], operands[1]); DONE; } - [(set_attr "length" "8,8,8,8,12,12,8")]) + [(set_attr "length" "8,8,8,12,12,8")]) (define_insn_and_split "*mov_32bit" [(set (match_operand:FMOVE128_FPR 0 "nonimmediate_operand" "=m,d,d,d,Y,r,r") - (match_operand:FMOVE128_FPR 1 "input_operand" "d,m,d,j,r,jY,r"))] + (match_operand:FMOVE128_FPR 1 "input_operand" "d,m,d,,r,jY,r"))] "TARGET_HARD_FLOAT && TARGET_FPRS && !TARGET_POWERPC64 && (FLOAT128_2REG_P (mode) || int_reg_operand_not_pseudo (operands[0], mode) diff --git a/gcc/testsuite/gcc.dg/dfp/pr70052.c b/gcc/testsuite/gcc.dg/dfp/pr70052.c new file mode 100644 index 0000000..53eb075 --- /dev/null +++ b/gcc/testsuite/gcc.dg/dfp/pr70052.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-options "-O1" } */ + +typedef struct +{ + _Decimal128 td0; + _Decimal128 td1; +} TDx2_t; + + +TDx2_t +D256_add_finite (void) +{ + _Decimal128 z, zz; + TDx2_t result = {0.DL, 0.DL}; + + if (zz == 0.DL) + { + result.td0 = z; + return result; + } + + return result; +}