From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 119857 invoked by alias); 16 Dec 2015 00:15:47 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 119788 invoked by uid 89); 16 Dec 2015 00:15:47 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-HELO: mail-wm0-f46.google.com Received: from mail-wm0-f46.google.com (HELO mail-wm0-f46.google.com) (74.125.82.46) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 16 Dec 2015 00:15:38 +0000 Received: by mail-wm0-f46.google.com with SMTP id n186so49250203wmn.0 for ; Tue, 15 Dec 2015 16:15:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=r2m5VqpdOrCLL1SUF6QprlbfinJ+TObq0gK7R49Il18=; b=Zd3Cv44xND07m2OT02oBhwgQSGU3fvMMb/fG+gRt9NNKk3tk74B8Oiyk+UO86uWyuh E4f1XcgwaUgKJZqbYVq0riijUCehpD9J0rwC63n6PsT0/5AMvwshP50JyeflGyTqCk+0 1hQlfYJWl6W+LN5dJaAccsfAgxc2C9qyDocUaUoTVAfTMmpWsrwr7nHUzU3dqxde2AWx iames6j6vdfUWpazpQdfk2U/Q7NSxmt5X649yd9y06MztPOJlVnwTZEWKkH+Ht8t9KYM uqgceKLSAIkpPWso25HYDPc4iuJ36xfssgorJrWujFisGsgWD7rPVeDNIK/pBwFRO4h0 S6wA== X-Gm-Message-State: ALoCoQn73MqbT8Sq4kJvDURxD6jobyEVETxqwlPFdEpDmNZ3H9GzSUtbYHHmgsRYFgUXuefjhCEBQBfYrAGZ6vqIj3H/TUx4hQ== X-Received: by 10.194.90.243 with SMTP id bz19mr47849188wjb.128.1450224935049; Tue, 15 Dec 2015 16:15:35 -0800 (PST) Received: from localhost (host86-138-95-213.range86-138.btcentralplus.com. [86.138.95.213]) by smtp.gmail.com with ESMTPSA id wh10sm3489099wjb.45.2015.12.15.16.15.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Dec 2015 16:15:34 -0800 (PST) From: Andrew Burgess To: gcc-patches@gcc.gnu.org Cc: Claudiu.Zissulescu@synopsys.com, gnu@amylaar.uk, Andrew Burgess Subject: [PATCH 4/4] gcc/arc: Avoid JUMP_LABEL_AS_INSN for possible return jumps Date: Wed, 16 Dec 2015 00:15:00 -0000 Message-Id: In-Reply-To: References: In-Reply-To: References: X-IsSubscribed: yes X-SW-Source: 2015-12/txt/msg01544.txt.bz2 We currently call JUMP_LABEL_AS_INSN on a jump instruction that might have SIMPLE_RETURN as it's jump label, this triggers the assertions as SIMPLE_RETURN is of type rtx_extra, not rtx_insn. This commit first calls JUMP_LABEL then uses ANY_RETURN_P to catch all of the return style jump labels. After this we can use the safe_as_a cast mechanism to safely convert the jump label to an rtx_insn. There's a test included, but this issue is also hit in the tests: gcc.c-torture/execute/20000605-2.c gcc.dg/torture/pr68083.c gcc/ChangeLog: * config/arc/arc.c (arc_loop_hazard): Don't convert the jump label rtx to an rtx_insn until we confirm it's not a return rtx. gcc/testsuite/ChangeLog: * gcc.target/arc/loop-hazard-1.c: New file. --- gcc/ChangeLog | 5 +++++ gcc/config/arc/arc.c | 15 ++++++++------- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.target/arc/loop-hazard-1.c | 16 ++++++++++++++++ 4 files changed, 33 insertions(+), 7 deletions(-) create mode 100644 gcc/testsuite/gcc.target/arc/loop-hazard-1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index dcc0930..bd2621d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2015-12-09 Andrew Burgess + * config/arc/arc.c (arc_loop_hazard): Don't convert the jump label + rtx to an rtx_insn until we confirm it's not a return rtx. + +2015-12-09 Andrew Burgess + * config/arc/arc.md (*storeqi_update): Use 'memory_operand' and fix RTL pattern to include the plus. (*storehi_update): Likewise. diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c index 5bc2bce..2c0f8b9 100644 --- a/gcc/config/arc/arc.c +++ b/gcc/config/arc/arc.c @@ -7987,6 +7987,7 @@ static bool arc_loop_hazard (rtx_insn *pred, rtx_insn *succ) { rtx_insn *jump = NULL; + rtx label_rtx = NULL_RTX; rtx_insn *label = NULL; basic_block succ_bb; @@ -8013,22 +8014,22 @@ arc_loop_hazard (rtx_insn *pred, rtx_insn *succ) else return false; - label = JUMP_LABEL_AS_INSN (jump); - if (!label) - return false; - /* Phase 2b: Make sure is not a millicode jump. */ if ((GET_CODE (PATTERN (jump)) == PARALLEL) && (XVECEXP (PATTERN (jump), 0, 0) == ret_rtx)) return false; - /* Phase 2c: Make sure is not a simple_return. */ - if ((GET_CODE (PATTERN (jump)) == SIMPLE_RETURN) - || (GET_CODE (label) == SIMPLE_RETURN)) + label_rtx = JUMP_LABEL (jump); + if (!label_rtx) + return false; + + /* Phase 2c: Make sure is not a return. */ + if (ANY_RETURN_P (label_rtx)) return false; /* Pahse 2d: Go to the target of the jump and check for aliveness of LP_COUNT register. */ + label = safe_as_a (label_rtx); succ_bb = BLOCK_FOR_INSN (label); if (!succ_bb) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6ab629a..b98706f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,9 @@ 2015-12-09 Andrew Burgess + * gcc.target/arc/loop-hazard-1.c: New file. + +2015-12-09 Andrew Burgess + * gcc.target/arc/load-update.c: New file. 2015-12-09 Andrew Burgess diff --git a/gcc/testsuite/gcc.target/arc/loop-hazard-1.c b/gcc/testsuite/gcc.target/arc/loop-hazard-1.c new file mode 100644 index 0000000..7c688bb --- /dev/null +++ b/gcc/testsuite/gcc.target/arc/loop-hazard-1.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-Os" } */ + +/* This caused an assertion within arc_loop_hazard. */ + +unsigned a, b; + +long fn1() +{ + long c = 1, d = 0; + while (a && c && b) + c <<= 1; + while (c) + d |= c; + return d; +} -- 2.5.1