From patchwork Fri May 20 14:11:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Suchanek X-Patchwork-Id: 624499 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 3rB8yV1Gj8z9t3r for ; Sat, 21 May 2016 00:12:17 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=fmGOg9mz; 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:from :to:cc:subject:date:message-id:content-type :content-transfer-encoding:mime-version; q=dns; s=default; b=K5e BwShKpCG32t8n6ZOaKcxgUBDBRnVZp66LGxURXKl9z6ayZFEsquVSZJsFKfmkC97 OVowNk7oSwjONynwG8F6nWSBu55WD47nugy8z1BStfJtG77AnpF3sqEJAcalydFM 9Ti+XTsYuFPtilgYnDIyChHRle7wcyTASuXrXtgY= 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 :to:cc:subject:date:message-id:content-type :content-transfer-encoding:mime-version; s=default; bh=MwCc+tDVb DpKDZA/zWq6AAg+JxE=; b=fmGOg9mzOQFxirjhx5dPpiwflhgslPzMvZzH0MLXL UW13gcue76zbSVVHUpB/99D2DFf7dWlBV9tbZGKlJ2DqkybMUJwWi2CVOckmma4T gBo6iqebL0h6oH/C/jcx0VzI1uyzr+JF+Q+CEkzS/Agg4KmtKRu+9tNqGmT9Y0nX bM= Received: (qmail 10697 invoked by alias); 20 May 2016 14:12:07 -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 10664 invoked by uid 89); 20 May 2016 14:12:05 -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, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=bennett, Bennett, sk:andrew, sk:andrew. X-HELO: mailapp01.imgtec.com Received: from mailapp01.imgtec.com (HELO mailapp01.imgtec.com) (195.59.15.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 20 May 2016 14:11:55 +0000 Received: from HHMAIL01.hh.imgtec.org (unknown [10.100.10.19]) by Websense Email with ESMTPS id 87318A38874D8; Fri, 20 May 2016 15:11:49 +0100 (IST) Received: from hhmail02.hh.imgtec.org ([fe80::5400:d33e:81a4:f775]) by HHMAIL01.hh.imgtec.org ([fe80::710b:f219:72bc:e0b3%26]) with mapi id 14.03.0266.001; Fri, 20 May 2016 15:11:52 +0100 From: Robert Suchanek To: Matthew Fortune , "Catherine_Moore@mentor.com" CC: "gcc-patches@gcc.gnu.org" Subject: [PATCH][MIPS] Fix ICE for constant pool data in GP area for MIPS16 Date: Fri, 20 May 2016 14:11:51 +0000 Message-ID: MIME-Version: 1.0 X-IsSubscribed: yes Hi, The patch fixes an ICE when the compiler tries to split an instruction. Test attached. No regression. Ok to apply? Regards, Robert gcc/ 2016-05-20 Andrew Bennett * config/mips/mips.c (mips_constant_pool_symbol_in_sdata_p): New function. (mips_output_move): Copy GP instead of splitting HIGH when accessing constant pool data. gcc/testsuite/ 2016-05-20 Robert Suchanek * gcc.target/mips/mips16-gp-bug-1.c: New test. --- gcc/config/mips/mips.c | 20 +++++++++++++++++++- gcc/testsuite/gcc.target/mips/mips16-gp-bug-1.c | 12 ++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/mips/mips16-gp-bug-1.c diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c index cbe1007..e6d8f76 100644 --- a/gcc/config/mips/mips.c +++ b/gcc/config/mips/mips.c @@ -5053,6 +5053,18 @@ mips_split_move_insn (rtx dest, rtx src, rtx insn) mips_split_move (dest, src, mips_insn_split_type (insn)); } +/* Return true if X is a GP-relative symbol in the constant pool. + CONTEXT is the context in which X appears. */ + +bool +mips_constant_pool_symbol_in_sdata_p (rtx x, enum mips_symbol_context context) +{ + enum mips_symbol_type symbol_type; + return (mips_symbolic_constant_p (x, context, &symbol_type) + && symbol_type == SYMBOL_GP_RELATIVE + && CONSTANT_POOL_ADDRESS_P (x)); +} + /* Return the appropriate instructions to move SRC into DEST. Assume that SRC is operand 1 and DEST is operand 0. */ @@ -5202,7 +5214,13 @@ mips_output_move (rtx dest, rtx src) } if (src_code == HIGH) - return TARGET_MIPS16 ? "#" : "lui\t%0,%h1"; + { + if (mips_constant_pool_symbol_in_sdata_p (XEXP (src, 0), + SYMBOL_CONTEXT_MEM)) + return "move\t%0,$28"; + + return TARGET_MIPS16 ? "#" : "lui\t%0,%h1"; + } if (CONST_GP_P (src)) return "move\t%0,%1"; diff --git a/gcc/testsuite/gcc.target/mips/mips16-gp-bug-1.c b/gcc/testsuite/gcc.target/mips/mips16-gp-bug-1.c new file mode 100644 index 0000000..85a6d83 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/mips16-gp-bug-1.c @@ -0,0 +1,12 @@ +/* { dg-options "(-mips16) -G4 -mno-abicalls -mcode-readable=no" } */ +typedef struct { int a, b, c, d; } A[5000]; +int a, b; +extern void bar (int, int, A); + +void +foo (int p1) +{ + A c; + while (p1) + bar (a, b, c); +}