From patchwork Mon Nov 14 16:57:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Stubbs X-Patchwork-Id: 82146 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp1104645qge; Mon, 14 Nov 2016 08:58:31 -0800 (PST) X-Received: by 10.98.95.193 with SMTP id t184mr37507860pfb.85.1479142711341; Mon, 14 Nov 2016 08:58:31 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id g23si5351645pfe.198.2016.11.14.08.58.31 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Nov 2016 08:58:31 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-441381-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-441381-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-441381-patch=linaro.org@gcc.gnu.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :subject:to:message-id:date:mime-version:content-type; q=dns; s= default; b=soUFdj09RwgG0+8HOGyDX56uCQFM4K6VqwB7/bjsiUGGszLMzefE8 IRwDm/nPDIyPZViTlVVUSgeA/QynnQdnSmIiEs+Rdx6LG2gSPHYjhvedP4INkzmb trddDuMW9JzagsZrcmi3oEIb1hNltmWVVQT5MHFB385N1NYIiZ2KtY= 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:from :subject:to:message-id:date:mime-version:content-type; s= default; bh=MtfbWsQx2dKOuhwZmvyfERNFmM0=; b=ixWm4S+b8hjU5oVKd0Sc wDfTlhiwICcP3Unv3t7QhB2LIB/g/ubbEh7GuNi/MeegJ1h9mehZlVSKsMphG4jy VCfjFgnDuOlc95nDHyGwREF2DT8RNEhHdTqdJuPZiSaBsnMUsG7+MD0pBczwTlXM NBQ1P0E6wTl1U0Sd3cEz7sI= Received: (qmail 80625 invoked by alias); 14 Nov 2016 16:58:17 -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 80608 invoked by uid 89); 14 Nov 2016 16:58:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS, URIBL_RED autolearn=ham version=3.3.2 spammy=taught, power7, A32, sk:offsett X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 14 Nov 2016 16:58:06 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=svr-ies-mbx-01.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1c6Ka3-0002wI-If from Andrew_Stubbs@mentor.com for gcc-patches@gcc.gnu.org; Mon, 14 Nov 2016 08:58:04 -0800 Received: from [172.30.64.241] (137.202.0.87) by svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Mon, 14 Nov 2016 16:58:00 +0000 From: Andrew Stubbs Subject: [PATCH][PPC] Fix ICE using power9 with soft-float To: "gcc-patches@gcc.gnu.org" Message-ID: <0065c16a-d7c3-1237-9deb-73400a9cd0c8@codesourcery.com> Date: Mon, 14 Nov 2016 16:57:58 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) The testcase powerpc/fusion3.c causes an ICE when compiled with -msoft-float. The key line in the testcase looks fairly harmless: void fusion_float_write (float *p, float f){ p[LARGE] = f; } The error message look like this: .../gcc.target/powerpc/fusion3.c: In function 'fusion_float_write':^M .../gcc.target/powerpc/fusion3.c:12:1: error: unrecognizable insn:^M (insn 18 4 14 2 (parallel [^M (set (mem:SF (plus:SI (plus:SI (reg:SI 3 3 [ p ])^M (const_int 327680 [0x50000]))^M (const_int -29420 [0xffffffffffff8d14])) [1 MEM[(float *)p_1(D) + 298260B]+0 S4 A32])^M (unspec:SF [^M (reg:SF 4 4 [ f ])^M ] UNSPEC_FUSION_P9))^M (clobber (reg/f:SI 3 3 [157]))^M ]) "/scratch/astubbs/fsf/src/gcc-mainline/gcc/testsuite/gcc.target/powerpc/fusion3.c":12 -1^M (nil))^M Basically, the problem is that the peephole optimization tries to create a Power9 Fusion instruction, but those do not support SF values in integer registers (AFAICT). So, presumably, I need to adjust either the predicate or the condition of the peephole rules. The predicate used is "toc_fusion_or_p9_reg_operand", and this might be the root cause, but I don't know the architecture well enough to be sure. The predicate code seems to suggest that "toc_fusion", whatever that is, should be able to do this, but the insn produced by the peephole uses only UNSPEC_FUSION_P9, which does not. Perhaps this predicate is inappropriate for the P9 Fusion peephole, or perhaps it needs to be taught about this corner case? In any case, I don't want to change the predicate without being sure what it does (here and elsewhere), so the attached patch solves the problem by changing the condition. Is this OK, or do I need to do something less blunt? Thanks Andrew 2016-11-11 Andrew Stubbs gcc/ * config/rs6000/rs6000.md: Disable P9-fusion peepholes when TARGET_SOFT_FLOAT is set. gcc/testsuite/ * gcc.target/powerpc/fusion3.c: Skip on -msoft-float. diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index de959c9..28d8174 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -13024,7 +13024,8 @@ (set (match_operand:SFDF 2 "toc_fusion_or_p9_reg_operand" "") (match_operand:SFDF 3 "fusion_offsettable_mem_operand" ""))] "TARGET_P9_FUSION && peep2_reg_dead_p (2, operands[0]) - && fusion_p9_p (operands[0], operands[1], operands[2], operands[3])" + && fusion_p9_p (operands[0], operands[1], operands[2], operands[3]) + && !TARGET_SOFT_FLOAT" [(const_int 0)] { expand_fusion_p9_load (operands); @@ -13037,7 +13038,8 @@ (set (match_operand:SFDF 2 "offsettable_mem_operand" "") (match_operand:SFDF 3 "toc_fusion_or_p9_reg_operand" ""))] "TARGET_P9_FUSION && peep2_reg_dead_p (2, operands[0]) - && fusion_p9_p (operands[0], operands[1], operands[2], operands[3])" + && fusion_p9_p (operands[0], operands[1], operands[2], operands[3]) + && !TARGET_SOFT_FLOAT" [(const_int 0)] { expand_fusion_p9_store (operands); @@ -13050,7 +13052,8 @@ (set (match_dup 0) (ior:SDI (match_dup 0) (match_operand:SDI 2 "u_short_cint_operand" "")))] - "TARGET_P9_FUSION" + "TARGET_P9_FUSION + && !TARGET_SOFT_FLOAT" [(set (match_dup 0) (unspec:SDI [(match_dup 1) (match_dup 2)] UNSPEC_FUSION_P9))]) @@ -13063,7 +13066,8 @@ (match_operand:SDI 3 "u_short_cint_operand" "")))] "TARGET_P9_FUSION && !rtx_equal_p (operands[0], operands[2]) - && peep2_reg_dead_p (2, operands[0])" + && peep2_reg_dead_p (2, operands[0]) + && !TARGET_SOFT_FLOAT" [(set (match_dup 2) (unspec:SDI [(match_dup 1) (match_dup 3)] UNSPEC_FUSION_P9))]) diff --git a/gcc/testsuite/gcc.target/powerpc/fusion3.c b/gcc/testsuite/gcc.target/powerpc/fusion3.c index 8eca640..20992d0 100644 --- a/gcc/testsuite/gcc.target/powerpc/fusion3.c +++ b/gcc/testsuite/gcc.target/powerpc/fusion3.c @@ -2,6 +2,7 @@ /* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */ /* { dg-require-effective-target powerpc_p9vector_ok } */ /* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power7" } } */ +/* { dg-skip-if "-mpower9-fusion and -msoft-float are incompatible" { powerpc*-*-* } { "-msoft-float" } {} } */ /* { dg-options "-mcpu=power7 -mtune=power9 -O3" } */ #define LARGE 0x12345