From patchwork Sat Oct 9 08:42:55 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 67316 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 0FD0DB70F5 for ; Sat, 9 Oct 2010 19:50:41 +1100 (EST) Received: (qmail 8639 invoked by alias); 9 Oct 2010 08:50:40 -0000 Received: (qmail 8625 invoked by uid 22791); 9 Oct 2010 08:50:39 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (212.99.106.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 09 Oct 2010 08:50:31 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id C5662CB0266; Sat, 9 Oct 2010 10:50:28 +0200 (CEST) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id AjFnV1iy6tuB; Sat, 9 Oct 2010 10:50:28 +0200 (CEST) Received: from [192.168.1.2] (bon31-9-83-155-120-49.fbx.proxad.net [83.155.120.49]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id 959E3CB0240; Sat, 9 Oct 2010 10:50:28 +0200 (CEST) From: Eric Botcazou To: Ian Lance Taylor Subject: Re: PATCH RFC: Clean up TREE_THIS_NOTRAP, copy it to MEM_REF Date: Sat, 9 Oct 2010 10:42:55 +0200 User-Agent: KMail/1.9.9 Cc: gcc-patches@gcc.gnu.org References: In-Reply-To: MIME-Version: 1.0 Content-Disposition: inline Message-Id: <201010091042.55179.ebotcazou@adacore.com> 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 > 2) When the gimplifier creates a MEM_REF for an INDIRECT_REF, it copies > over the TREE_THIS_NOTRAP flag. This is the more important part of > the change, as it improves the generated code when using > -fnon-call-exceptions. Thanks for caring about -fnon-call-exceptions. :-) > This patch is entirely in the middle-end, so I do not need approval. > However, I would like to know if there are any comments on this before I > commit it. The TREE_THIS_NOTRAP flag can get lost during inlining. We have the attached hunks in our 4.5-based tree (to be adjusted to MEM_REF). The sched-deps.c hunk is for the IA-64 because it abuses may_trap_p to detect non-speculative instructions; when the TREE_THIS_NOTRAP is set, may_trap_p returns false, although the instruction is still as speculative as without it. * sched-deps.c (sched_insn_is_legitimate_for_speculation): Invoke may_trap_or_fault_p instead of may_trap_p predicate. * tree.c (substitute_in_expr): Propagate the TREE_THIS_NOTRAP flag. (substitute_placeholder_in_expr): Likewise. * tree-inline.c (remap_gimple_op_r): Propagate the TREE_READONLY and TREE_THIS_NOTRAP flags on INDIRECT_REF nodes. (copy_tree_body_r): Likewise. *** gcc/sched-deps.c.0 2010-09-27 23:58:17.000000000 +0200 --- gcc/sched-deps.c 2010-09-28 00:03:05.000000000 +0200 *************** sched_insn_is_legitimate_for_speculation *** 597,604 **** /* The following instructions, which depend on a speculatively scheduled instruction, cannot be speculatively scheduled along. */ { ! if (may_trap_p (PATTERN (insn))) ! /* If instruction might trap, it cannot be speculatively scheduled. For control speculation it's obvious why and for data speculation it's because the insn might get wrong input if speculation wasn't successful. */ --- 597,604 ---- /* The following instructions, which depend on a speculatively scheduled instruction, cannot be speculatively scheduled along. */ { ! if (may_trap_or_fault_p (PATTERN (insn))) ! /* If instruction might fault, it cannot be speculatively scheduled. For control speculation it's obvious why and for data speculation it's because the insn might get wrong input if speculation wasn't successful. */ *** gcc/tree.c.0 2010-09-26 13:31:06.000000000 +0200 --- gcc/tree.c 2010-09-26 17:25:20.000000000 +0200 *************** substitute_in_expr (tree exp, tree f, tr *** 3133,3138 **** --- 3133,3142 ---- } TREE_READONLY (new_tree) |= TREE_READONLY (exp); + + if (code == INDIRECT_REF || code == ARRAY_REF || code == ARRAY_RANGE_REF) + TREE_THIS_NOTRAP (new_tree) |= TREE_THIS_NOTRAP (exp); + return new_tree; } *************** substitute_placeholder_in_expr (tree exp *** 3300,3305 **** --- 3304,3313 ---- } TREE_READONLY (new_tree) |= TREE_READONLY (exp); + + if (code == INDIRECT_REF || code == ARRAY_REF || code == ARRAY_RANGE_REF) + TREE_THIS_NOTRAP (new_tree) |= TREE_THIS_NOTRAP (exp); + return new_tree; } *** gcc/tree-inline.c.0 2010-09-26 13:30:54.000000000 +0200 --- gcc/tree-inline.c 2010-09-26 13:41:34.000000000 +0200 *************** remap_gimple_op_r (tree *tp, int *walk_s *** 845,850 **** --- 845,852 ---- *tp = build1 (INDIRECT_REF, type, new_tree); TREE_THIS_VOLATILE (*tp) = TREE_THIS_VOLATILE (old); TREE_NO_WARNING (*tp) = TREE_NO_WARNING (old); + TREE_READONLY (*tp) = TREE_READONLY (old); + TREE_THIS_NOTRAP (*tp) = TREE_THIS_NOTRAP (old); } } *walk_subtrees = 0; *************** copy_tree_body_r (tree *tp, int *walk_su *** 1080,1085 **** --- 1082,1089 ---- *tp = build1 (INDIRECT_REF, type, new_tree); TREE_THIS_VOLATILE (*tp) = TREE_THIS_VOLATILE (old); TREE_SIDE_EFFECTS (*tp) = TREE_SIDE_EFFECTS (old); + TREE_READONLY (*tp) = TREE_READONLY (old); + TREE_THIS_NOTRAP (*tp) = TREE_THIS_NOTRAP (old); } } *walk_subtrees = 0;