From patchwork Wed Jan 19 20:02:05 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 79585 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]) by ozlabs.org (Postfix) with SMTP id 87421B708B for ; Thu, 20 Jan 2011 07:02:16 +1100 (EST) Received: (qmail 12954 invoked by alias); 19 Jan 2011 20:02:15 -0000 Received: (qmail 12944 invoked by uid 22791); 19 Jan 2011 20:02:14 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_TM, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 19 Jan 2011 20:02:09 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p0JK27Ia001505 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 19 Jan 2011 15:02:07 -0500 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p0JK26xP032560 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 19 Jan 2011 15:02:07 -0500 Received: from tyan-ft48-01.lab.bos.redhat.com (localhost.localdomain [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id p0JK25HM011918; Wed, 19 Jan 2011 21:02:05 +0100 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id p0JK25lB011917; Wed, 19 Jan 2011 21:02:05 +0100 Date: Wed, 19 Jan 2011 21:02:05 +0100 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Cc: Jan Hubicka Subject: [PATCH] Fix ipa-split if there are extra PHIs on the return_bb (PR tree-optimization/46130) Message-ID: <20110119200205.GU2724@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes 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 Hi! ipa-split fixes the (single) virtual operand PHI and at most one normal PHI - if it returns a gimple value from the *.part.* function. If there are other PHIs, it will ICE because nothing fixes them up (we'd need function with multiple return values for them). Generally this should happen only if DCE didn't do a good job. In whole x86_64-linux and i686-linux bootstraps/regtests this triggered just on the added testcases. Bootstrapped/regtested on those 2 targets, ok for trunk? 2011-01-19 Jakub Jelinek PR tree-optimization/46130 * ipa-split.c (consider_split): If return_bb contains non-virtual PHIs other than for retval or if split_function would not adjust it, refuse to split. * gcc.dg/pr46130-1.c: New test. * gcc.dg/pr46130-2.c: New test. Jakub --- gcc/ipa-split.c.jj 2011-01-19 15:29:25.000000000 +0100 +++ gcc/ipa-split.c 2011-01-19 18:17:34.000000000 +0100 @@ -411,9 +411,6 @@ consider_split (struct split_point *curr " Refused: split part has non-ssa uses\n"); return; } - if (dump_file && (dump_flags & TDF_DETAILS)) - fprintf (dump_file, " Accepted!\n"); - /* See if retval used by return bb is computed by header or split part. When it is computed by split part, we need to produce return statement in the split part and add code to header to pass it around. @@ -451,6 +448,30 @@ consider_split (struct split_point *curr else current->split_part_set_retval = true; + /* split_function fixes up at most one PHI non-virtual PHI node in return_bb, + for the return value. If there are other PHIs, give up. */ + if (return_bb != EXIT_BLOCK_PTR) + { + gimple_stmt_iterator psi; + + for (psi = gsi_start_phis (return_bb); !gsi_end_p (psi); gsi_next (&psi)) + if (is_gimple_reg (gimple_phi_result (gsi_stmt (psi))) + && !(retval + && current->split_part_set_retval + && TREE_CODE (retval) == SSA_NAME + && !DECL_BY_REFERENCE (DECL_RESULT (current_function_decl)) + && SSA_NAME_DEF_STMT (retval) == gsi_stmt (psi))) + { + if (dump_file && (dump_flags & TDF_DETAILS)) + fprintf (dump_file, + " Refused: return bb has extra PHIs\n"); + return; + } + } + + if (dump_file && (dump_flags & TDF_DETAILS)) + fprintf (dump_file, " Accepted!\n"); + /* At the moment chose split point with lowest frequency and that leaves out smallest size of header. In future we might re-consider this heuristics. */ --- gcc/testsuite/gcc.dg/pr46130-1.c.jj 2011-01-19 18:24:13.000000000 +0100 +++ gcc/testsuite/gcc.dg/pr46130-1.c 2011-01-19 18:32:07.000000000 +0100 @@ -0,0 +1,23 @@ +/* PR tree-optimization/46130 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-tree-dce" } */ + +#include + +static void +foo (va_list ap) +{ + va_arg (ap, char *)[0]; +} + +void +bar (va_list ap) +{ + foo (ap); +} + +void +baz (va_list ap) +{ + foo (ap); +} --- gcc/testsuite/gcc.dg/pr46130-2.c.jj 2011-01-19 18:24:10.000000000 +0100 +++ gcc/testsuite/gcc.dg/pr46130-2.c 2011-01-19 18:24:05.000000000 +0100 @@ -0,0 +1,32 @@ +/* PR tree-optimization/46130 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-tree-dce" } */ + +extern int bar (int); + +static int foo (int x) +{ + int z, w; + if (x <= 1024) + { + z = 16; + w = 17; + } + else + { + bar (bar (bar (bar (bar (bar (bar (bar (bar (16))))))))); + if (x > 131072) + w = 19; + else + w = 21; + z = 32; + } + w = w + 121; + return z; +} + +int +baz (int x) +{ + return foo (x + 6) + foo (x + 15) + foo (x + 24); +}