From patchwork Fri Apr 13 08:56:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 897890 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-476328-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ucw.cz Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="sy7XeTkr"; dkim-atps=neutral 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 40Ms8L0M4Fz9s0W for ; Fri, 13 Apr 2018 18:56:32 +1000 (AEST) 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=LFG00HUWEu8On+GTgd9Y/UdjxQWyrIkKmCqULCT8KBTlOTB1Non+1 79mFXb63FJ6ookt2Gtu6cJm7kC8AhzvBKg6477SkI0O72+Wzzr2ZKDCdAxjbBQpa 0O1oJw84pgqMfzTLFvu8uXeXI9Gv3ROIYZD4aCKSgSbYkaxaUAikE0= 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=Lny2JJByJqoVkbQqDNvuL718nuQ=; b=sy7XeTkrNCrn6qu8g76x +7Y5daH1TxTkI7L8kTz6SY3g2CdAiuxcgHlv56YGWDyFLYsyjQ/G7uBctLFuNQFN 0ka4e4pHj7CMte67HavkosP7RJBnsKkisKOTxDUlGWcYAH34k28pYrFrR9YlSoaS muidpeKsSWyvXIpUfpB6AZg= Received: (qmail 60305 invoked by alias); 13 Apr 2018 08:56:24 -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 60245 invoked by uid 89); 13 Apr 2018 08:56:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-9.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY autolearn=ham version=3.3.2 spammy=zen, fn1 X-HELO: nikam.ms.mff.cuni.cz Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 13 Apr 2018 08:56:16 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 5629C542D58; Fri, 13 Apr 2018 10:56:13 +0200 (CEST) Date: Fri, 13 Apr 2018 10:56:13 +0200 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: Be more permissive for always inlining across target attribute changes Message-ID: <20180413085613.GA55263@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) Hi, this patch makes it possible to always inline across target attribute changes when doing so will not lead to incorrect code. We used to be permissive here with default options and overly restrictie without. This fixes most common anoyances seen with these, but not all (i.e. zen) Bootstrapped/regteste x86_64-linux, commited. Honza PR lto/71991 * config/i386/i386.c (ix86_can_inline_p): Allow safe transitions for always inline. * gcc.target/i386/pr71991.c: New testcase. Index: config/i386/i386.c =================================================================== --- config/i386/i386.c (revision 259345) +++ config/i386/i386.c (working copy) @@ -5766,6 +5766,19 @@ ix86_can_inline_p (tree caller, tree cal { tree caller_tree = DECL_FUNCTION_SPECIFIC_TARGET (caller); tree callee_tree = DECL_FUNCTION_SPECIFIC_TARGET (callee); + + /* Changes of those flags can be tolerated for always inlines. Lets hope + user knows what he is doing. */ + const unsigned HOST_WIDE_INT always_inline_safe_mask + = (MASK_USE_8BIT_IDIV | MASK_ACCUMULATE_OUTGOING_ARGS + | MASK_NO_ALIGN_STRINGOPS | MASK_AVX256_SPLIT_UNALIGNED_LOAD + | MASK_AVX256_SPLIT_UNALIGNED_STORE | MASK_CLD + | MASK_NO_FANCY_MATH_387 | MASK_IEEE_FP | MASK_INLINE_ALL_STRINGOPS + | MASK_INLINE_STRINGOPS_DYNAMICALLY | MASK_RECIP | MASK_STACK_PROBE + | MASK_STV | MASK_TLS_DIRECT_SEG_REFS | MASK_VZEROUPPER + | MASK_NO_PUSH_ARGS | MASK_OMIT_LEAF_FRAME_POINTER); + + if (!callee_tree) callee_tree = target_option_default_node; if (!caller_tree) @@ -5776,6 +5789,10 @@ ix86_can_inline_p (tree caller, tree cal struct cl_target_option *caller_opts = TREE_TARGET_OPTION (caller_tree); struct cl_target_option *callee_opts = TREE_TARGET_OPTION (callee_tree); bool ret = false; + bool always_inline = + (DECL_DISREGARD_INLINE_LIMITS (callee) + && lookup_attribute ("always_inline", + DECL_ATTRIBUTES (callee))); /* Callee's isa options should be a subset of the caller's, i.e. a SSE4 function can inline a SSE2 function but a SSE2 function can't inline @@ -5787,14 +5804,17 @@ ix86_can_inline_p (tree caller, tree cal ret = false; /* See if we have the same non-isa options. */ - else if (caller_opts->x_target_flags != callee_opts->x_target_flags) + else if ((!always_inline + && caller_opts->x_target_flags != callee_opts->x_target_flags) + || (caller_opts->x_target_flags & ~always_inline_safe_mask) + != (callee_opts->x_target_flags & ~always_inline_safe_mask)) ret = false; /* See if arch, tune, etc. are the same. */ else if (caller_opts->arch != callee_opts->arch) ret = false; - else if (caller_opts->tune != callee_opts->tune) + else if (!always_inline && caller_opts->tune != callee_opts->tune) ret = false; else if (caller_opts->x_ix86_fpmath != callee_opts->x_ix86_fpmath @@ -5807,7 +5827,8 @@ ix86_can_inline_p (tree caller, tree cal (cgraph_node::get (callee))->fp_expressions)) ret = false; - else if (caller_opts->branch_cost != callee_opts->branch_cost) + else if (!always_inline + && caller_opts->branch_cost != callee_opts->branch_cost) ret = false; else Index: testsuite/gcc.target/i386/pr71991.c =================================================================== --- testsuite/gcc.target/i386/pr71991.c (revision 0) +++ testsuite/gcc.target/i386/pr71991.c (working copy) @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ +static inline __attribute__ ((__always_inline__)) int fn1 () { return 0; } +static __attribute__ ((target ("inline-all-stringops"))) int fn2 () { fn1 (); } + +int main() +{ + fn2(); +} +