From patchwork Tue Jun 24 09:47:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 363349 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 7353F1400A7 for ; Tue, 24 Jun 2014 19:49:58 +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:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=mZrYLrmULvXjodsq1TdwkknE4wZjXQjKiLpn4gheIDA+ggc1UAzCs zNeV+IdCqLUVlfzK+HI2fd0Ikd29IiGl7/cmzT4lDBq419t4u4c1ZCVWxjaD1bZP VwhveM/PCMdfjew/nqoxtU+dutbNvS7ZSvvG3kHYcD0WdOPncBg3EQ= 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:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=GFXkhWWyp4qHIQl6k+uTc+7X8dU=; b=dEaV5aQFAUj7Qh3758Ji /GZ6HMGFcHD7qmtN69L0ushauGczSP3D/3uvNpr+w/fE7SMidPwSZSIFrW2n2PnY c7UhmoLQfda77V62v7jcUrQOLtDVdRwNX1z/0AyEoVkn8N7Zz293O0M51qZrmzPS NVL9kIiG9V93XSIQUQmvUEg= Received: (qmail 920 invoked by alias); 24 Jun 2014 09:49:51 -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 910 invoked by uid 89); 24 Jun 2014 09:49:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx2.suse.de Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Tue, 24 Jun 2014 09:49:50 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 79FCDAD6D for ; Tue, 24 Jun 2014 09:49:47 +0000 (UTC) Date: Tue, 24 Jun 2014 11:47:16 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] "Fix" PR61572 Message-ID: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 The following avoids to increase hard register lifetime by not sinking loads from those. Bootstrapped on x86_64-unknown-linux-gnu, testing in progress. I wonder if it would make sense to not treat hardregs as memory but instead rewrite them into SSA form but with SSA_NAME_OCCURS_IN_ABNORMAL_PHI set (which really tells that all SSA names of the underlying decl must be able to coalesce to the same register). Richard. 2014-06-24 Richard Biener PR tree-optimization/61572 * tree-ssa-sink.c (statement_sink_location): Do not sink loads from hard registers. * gcc.target/i386/pr61572.c: New testcase. Index: gcc/tree-ssa-sink.c =================================================================== --- gcc/tree-ssa-sink.c (revision 211928) +++ gcc/tree-ssa-sink.c (working copy) @@ -374,6 +374,12 @@ statement_sink_location (gimple stmt, ba nearest to commondom. */ if (gimple_vuse (stmt)) { + /* Do not sink loads from hard registers. */ + if (gimple_assign_single_p (stmt) + && TREE_CODE (gimple_assign_rhs1 (stmt)) == VAR_DECL + && DECL_HARD_REGISTER (gimple_assign_rhs1 (stmt))) + return false; + imm_use_iterator imm_iter; use_operand_p use_p; basic_block found = NULL; Index: gcc/testsuite/gcc.target/i386/pr61572.c =================================================================== --- gcc/testsuite/gcc.target/i386/pr61572.c (revision 0) +++ gcc/testsuite/gcc.target/i386/pr61572.c (working copy) @@ -0,0 +1,46 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +struct autofs_sb_info +{ + int exp_timeout; +}; +void *f; +int g; +static int fn1 (struct autofs_sb_info *p1) +{ + int a, b; + a = ( + { + register __typeof__(0) c +#if defined __x86_64__ + asm("rdx") +#endif + ; + b = c; + int d; + __typeof__(0) e; + e = p1->exp_timeout / 1000; + switch (0) + default: + asm("" : "=a"(d) : "0"(e), ""(0)); + d; + }); + if (a) + return 1; + if (b) + p1->exp_timeout = 0; + return 0; +} + +int fn2 () +{ + struct autofs_sb_info *h = f; + switch (g) + { + case 0 ?: +0 : return fn1 (h); + default: + return 0; + } +}