From patchwork Wed Oct 13 18:18:01 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 67720 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 61987B70EA for ; Thu, 14 Oct 2010 05:18:58 +1100 (EST) Received: (qmail 506 invoked by alias); 13 Oct 2010 18:18:56 -0000 Received: (qmail 498 invoked by uid 22791); 13 Oct 2010 18:18:54 -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; Wed, 13 Oct 2010 18:18:50 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 19DA1CB023F for ; Wed, 13 Oct 2010 20:18:48 +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 1+mZ2rxOwefm for ; Wed, 13 Oct 2010 20:18:48 +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 E8CACCB01DF for ; Wed, 13 Oct 2010 20:18:47 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: Minor tweaks to RTL CSE Date: Wed, 13 Oct 2010 20:18:01 +0200 User-Agent: KMail/1.9.9 MIME-Version: 1.0 Content-Disposition: inline Message-Id: <201010132018.02035.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 The attached patch makes a couple of minor tweaks to RTL CSE: 1. cse_insn canonicalizes top-level USEs by means of: /* Canonicalize a USE of a pseudo register or memory location. */ else if (GET_CODE (x) == USE && ! (REG_P (XEXP (x, 0)) && REGNO (XEXP (x, 0)) < FIRST_PSEUDO_REGISTER)) canon_reg (XEXP (x, 0), insn); There is a thinko: if you want to canonicalize XEXP (x, 0) and it is a pseudo, you must do canon_reg (x, insn) and not canon_reg (XEXP (x, 0), insn). This is done correctly a few lines above for embedded USEs: else if (GET_CODE (y) == USE && ! (REG_P (XEXP (y, 0)) && REGNO (XEXP (y, 0)) < FIRST_PSEUDO_REGISTER)) canon_reg (y, insn); 2. fold_rtx folds into ASM_OPERANDS_INPUT of ASM_OPERANDS: case ASM_OPERANDS: if (insn) { for (i = ASM_OPERANDS_INPUT_LENGTH (x) - 1; i >= 0; i--) validate_change (insn, &ASM_OPERANDS_INPUT (x, i), fold_rtx (ASM_OPERANDS_INPUT (x, i), insn), 0); } return x; but cse_insn doesn't. This missed optimization is problematic in Ada because we implement pragma Inspection_Point by means of a volatile asm and it can happen that CSE propagates a pseudo except into an ASM_OPERANDS, which can lead to a DEBUG_INSN referencing a dead pseudo and its subsequent resetting (although Jakub's patch I just reviewed may fix that up), i.e no debug info. Now pragma Inspection_Point is precisely about getting correct debug info... Bootstrapped/regtested on x86_64-suse-linux, applied on the mainline. 2010-10-13 Eric Botcazou * cse.c (cse_insn): Fix thinko in the canonicalization of USE insns. Canonicalize input operands of ASM_OPERANDS insns. Index: cse.c =================================================================== --- cse.c (revision 165411) +++ cse.c (working copy) @@ -4338,12 +4338,23 @@ cse_insn (rtx insn) if (MEM_P (XEXP (x, 0))) canon_reg (XEXP (x, 0), insn); } - /* Canonicalize a USE of a pseudo register or memory location. */ else if (GET_CODE (x) == USE && ! (REG_P (XEXP (x, 0)) && REGNO (XEXP (x, 0)) < FIRST_PSEUDO_REGISTER)) - canon_reg (XEXP (x, 0), insn); + canon_reg (x, insn); + else if (GET_CODE (x) == ASM_OPERANDS) + { + for (i = ASM_OPERANDS_INPUT_LENGTH (x) - 1; i >= 0; i--) + { + rtx input = ASM_OPERANDS_INPUT (x, i); + if (!(REG_P (input) && REGNO (input) < FIRST_PSEUDO_REGISTER)) + { + input = canon_reg (input, insn); + validate_change (insn, &ASM_OPERANDS_INPUT (x, i), input, 1); + } + } + } else if (GET_CODE (x) == CALL) { /* The result of apply_change_group can be ignored; see canon_reg. */