From patchwork Tue May 20 07:11:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhenqiang Chen X-Patchwork-Id: 350542 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 84CB914007F for ; Tue, 20 May 2014 17:11:20 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:cc:content-type; q=dns; s=default; b=h1UOPa4rKSwoaXvku1KtGJmyxaT25LYk8gSgVw8Qsa4 dwVSIgcC9mZfug6H6ued+1n0voYdaGl1rF5RyxVPuNNJXJAVdzlqSr79sCIYotiL 5FO9ugPXF1e5k1BYBjcOpxUD3moBjMb7NNRAS86LMTsowX969XzGTjzGGK7pEJ7E = 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 :mime-version:date:message-id:subject:from:to:cc:content-type; s=default; bh=GuIZeKgFL2ZMdPpzzLcjFvMP6wc=; b=pVQN5X54zwgf2qu1V fyI0C6+eN6j7s6X2WmhJu/+hZlnNpPsXcjB1YtUo9n2mgXtzSQIH8CirGPqer97J FXBXxHwah/60GN+trSmGDIl36G4+PW4S59BBjP1NZdK/TQSBN0p5JIhlxVh9ZuSo 2W2yTRRgUhe6PT408HuMhk8/8c= Received: (qmail 14572 invoked by alias); 20 May 2014 07:11:13 -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 14561 invoked by uid 89); 20 May 2014 07:11:13 -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, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-la0-f54.google.com Received: from mail-la0-f54.google.com (HELO mail-la0-f54.google.com) (209.85.215.54) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 20 May 2014 07:11:12 +0000 Received: by mail-la0-f54.google.com with SMTP id pv20so37915lab.27 for ; Tue, 20 May 2014 00:11:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to:cc :content-type; bh=64MWS/YnV2i3zHzDfXNs1ETbgxyiu4iS2X73cekzwBA=; b=WpzDcMTZCE7uav7J+vNbihkHHp2TamenArQwsqVyH/rU+0WaArHB2m9vZT9WXZaV5N u9gpthKtFtEWUNy+nPx6zpF8g4QEvYbucPVbOcBEVdImmqfT8of/3BNqWdS6twsN2erE 9R9dUH9WuWJetyVpWr/x47l/G9214i6pjZSo8SvvO0P4qnHZmwerROcT6H5Zg8/qQl+O uIX2LZ+woD5Qur5F9c1Stoyx0kdeEUko3BnI7uc4r0uClYQG6Fjix6jc2GJhmu+1jSoJ lUvLZzfTmnjMBu2nI6hm+QXikFq/pmpNpmH0kEOKBOAecHgmH2UfNz6xC7phZ3GRrrYL gPyQ== X-Gm-Message-State: ALoCoQlA4CAJQXAsdsTGHCkYeE9U2/j1rz+Q6GSJsru3z1PY8EfU/5DXPim4ZZnYz1AoI8AsZQ7y MIME-Version: 1.0 X-Received: by 10.152.29.200 with SMTP id m8mr10810222lah.49.1400569868585; Tue, 20 May 2014 00:11:08 -0700 (PDT) Received: by 10.112.13.36 with HTTP; Tue, 20 May 2014 00:11:08 -0700 (PDT) Date: Tue, 20 May 2014 15:11:08 +0800 Message-ID: Subject: [PATCH] Fix ICE in rtl-optimization/PR61220, PR61225 From: Zhenqiang Chen To: "gcc-patches@gcc.gnu.org" Cc: Jeff Law X-IsSubscribed: yes Hi, The patch fix ICE issue triggered by shrink-wrapping enhancement. Bootstrap and no make check regression on X86-64. OK for trunk? Thanks! -Zhenqiang 2014-05-20 Zhenqiang Chen PR rtl-optimization/61220 Part of PR rtl-optimization/61225 * shrink-wrap.c (move_insn_for_shrink_wrap): Skip SP and FP adjustment insn; skip split_edge for a block without only on successor. testsuite/ChangeLog: 2014-05-20 Zhenqiang Chen * gcc.dg/pr61220.c: New test. * gcc.dg/shrink-wrap-loop.c: Disable for x86_64 -m32 mode. diff --git a/gcc/shrink-wrap.c b/gcc/shrink-wrap.c index f09cfe7..6f1ddc7 100644 --- a/gcc/shrink-wrap.c +++ b/gcc/shrink-wrap.c @@ -179,7 +179,12 @@ move_insn_for_shrink_wrap (basic_block bb, rtx insn, return false; src = SET_SRC (set); dest = SET_DEST (set); - if (!REG_P (dest) || !REG_P (src)) + if (!REG_P (dest) || !REG_P (src) + /* STACK or FRAME related adjustment might be part of prologue. + So keep them in the entry block. */ + || dest == stack_pointer_rtx + || dest == frame_pointer_rtx + || dest == hard_frame_pointer_rtx) return false; /* Make sure that the source register isn't defined later in BB. */ @@ -204,6 +209,10 @@ move_insn_for_shrink_wrap (basic_block bb, rtx insn, /* Create a new basic block on the edge. */ if (EDGE_COUNT (next_block->preds) == 2) { + /* split_edge for a block with only one successor is meaningless. */ + if (EDGE_COUNT (bb->succs) == 1) + return false; + next_block = split_edge (live_edge); bitmap_copy (df_get_live_in (next_block), df_get_live_out (bb)); diff --git a/gcc/testsuite/gcc.dg/pr61220.c b/gcc/testsuite/gcc.dg/pr61220.c new file mode 100644 index 0000000..c503ff1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr61220.c @@ -0,0 +1,39 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -g" } */ + +int a, c, d, e, f, g, h, i, j, k; + +struct S0 +{ + int f0; + int f1; + int f2; +}; + +struct S1 +{ + int f0; + int f1; + struct S0 f2; +} b; + +void +fn1 (struct S1 p) +{ + for (; k; k++) + h = j ? a : a - 1; + d &= i; +} + +int +main () +{ + int l[5] = { 0 }; + fn1 (b); + for (c = 0; c < 3; c++) + for (g = 0; g < 3; g++) + l[c * 2] = e = l[c]; + if (f) + fn1 (b); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/shrink-wrap-loop.c b/gcc/testsuite/gcc.dg/shrink-wrap-loop.c index 17dca4e..e72edfa 100644 --- a/gcc/testsuite/gcc.dg/shrink-wrap-loop.c +++ b/gcc/testsuite/gcc.dg/shrink-wrap-loop.c @@ -1,4 +1,4 @@ -/* { dg-do compile { target { { x86_64-*-* } || { arm_thumb2 } } } } */ +/* { dg-do compile { target { { x86_64-*-* && lp64 } || { arm_thumb2 } } } } */ /* { dg-options "-O2 -fdump-rtl-pro_and_epilogue" } */ int foo (int *p1, int *p2);