From patchwork Sun Oct 18 20:03:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kugan Vivekanandarajah X-Patchwork-Id: 55213 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lf0-f69.google.com (mail-lf0-f69.google.com [209.85.215.69]) by patches.linaro.org (Postfix) with ESMTPS id 88A3722F11 for ; Sun, 18 Oct 2015 20:04:19 +0000 (UTC) Received: by lffv3 with SMTP id v3sf32924492lff.1 for ; Sun, 18 Oct 2015 13:04:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mailing-list:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:sender :delivered-to:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-type:x-original-sender :x-original-authentication-results; bh=zTSBmFcyeJl/7l3krhFCQxir50aTiVXlItq5EsVvWi4=; b=MI5tRN0hrC5/PTho/Qb0zFWezJfYKqlh6UXOUjoti8lWkswP7MA957A3QyXQZf4LcD Tsik3ZrKeGe+Fh2RLcNbGKRMvk+NRsDwfTJ+mI13NiYkMDjV0lE4AZTL7VS65Xpfd3a/ SAFMmKIc6YB59CMxMBbX1bhYroTxbKh25nqrKQRcOIO3qXe1ZEwmS59etf4eNJu21rTm b0WtSI0P/um3qh8Ype6J61vP0s7oOEafkrpiUAXm3IKMLBngoqbnaetYnrRWgeARqj/N lhkIrE23KskPEJZZnvbmQci026s3XyGtCXbH3zEuX5ZIa6MycfAabLey0dCw1DNlfjwf XpWw== X-Gm-Message-State: ALoCoQmoC/b3xN75y7Q7U+wYHSpMIYqvLjSYzi2pK6ltVooJMjSy9/NbfG0kYDCcPLbF1j4pHduH X-Received: by 10.180.105.98 with SMTP id gl2mr3541188wib.0.1445198658059; Sun, 18 Oct 2015 13:04:18 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.83.197 with SMTP id h188ls35461lfb.76.gmail; Sun, 18 Oct 2015 13:04:17 -0700 (PDT) X-Received: by 10.25.161.136 with SMTP id k130mr8506333lfe.25.1445198657908; Sun, 18 Oct 2015 13:04:17 -0700 (PDT) Received: from mail-lf0-x22b.google.com (mail-lf0-x22b.google.com. [2a00:1450:4010:c07::22b]) by mx.google.com with ESMTPS id q133si20338002lfe.171.2015.10.18.13.04.17 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Oct 2015 13:04:17 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c07::22b as permitted sender) client-ip=2a00:1450:4010:c07::22b; Received: by lfaz124 with SMTP id z124so97960240lfa.1 for ; Sun, 18 Oct 2015 13:04:17 -0700 (PDT) X-Received: by 10.25.40.130 with SMTP id o124mr8164445lfo.41.1445198657756; Sun, 18 Oct 2015 13:04:17 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp1105400lbq; Sun, 18 Oct 2015 13:04:15 -0700 (PDT) X-Received: by 10.68.131.6 with SMTP id oi6mr30119834pbb.3.1445198655405; Sun, 18 Oct 2015 13:04:15 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id ie4si47009206pbb.168.2015.10.18.13.04.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Oct 2015 13:04:15 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-410469-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 121288 invoked by alias); 18 Oct 2015 20:04:02 -0000 Mailing-List: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org Precedence: list 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 121278 invoked by uid 89); 18 Oct 2015 20:04:01 -0000 X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f53.google.com Received: from mail-pa0-f53.google.com (HELO mail-pa0-f53.google.com) (209.85.220.53) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Sun, 18 Oct 2015 20:04:00 +0000 Received: by padhk11 with SMTP id hk11so7455579pad.1 for ; Sun, 18 Oct 2015 13:03:58 -0700 (PDT) X-Received: by 10.68.104.66 with SMTP id gc2mr29582071pbb.21.1445198638101; Sun, 18 Oct 2015 13:03:58 -0700 (PDT) Received: from [10.1.1.5] (58-6-183-210.dyn.iinet.net.au. [58.6.183.210]) by smtp.googlemail.com with ESMTPSA id xm4sm32592511pab.27.2015.10.18.13.03.54 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Oct 2015 13:03:57 -0700 (PDT) Subject: Re: [5/7] Allow gimple debug stmt in widen mode To: Richard Biener References: <55ECFC2A.7050908@linaro.org> <55ECFE08.8060405@linaro.org> <55EE2523.6000209@linaro.org> <561F3D5B.4060709@linaro.org> Cc: Michael Matz , "gcc-patches@gcc.gnu.org" From: Kugan Message-ID: <5623FB27.6090301@linaro.org> Date: Mon, 19 Oct 2015 07:03:51 +1100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: X-IsSubscribed: yes X-Original-Sender: kugan.vivekanandarajah@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c07::22b as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@gcc.gnu.org X-Google-Group-Id: 836684582541 > You remove > > > @@ -5269,16 +5268,6 @@ expand_debug_locations (void) > > if (!val) > val = gen_rtx_UNKNOWN_VAR_LOC (); > - else > - { > - mode = GET_MODE (INSN_VAR_LOCATION (insn)); > - > - gcc_assert (mode == GET_MODE (val) > - || (GET_MODE (val) == VOIDmode > - && (CONST_SCALAR_INT_P (val) > - || GET_CODE (val) == CONST_FIXED > - || GET_CODE (val) == LABEL_REF))); > - } > > which is in place to ensure the debug insns are "valid" in some form(?) > On what kind of insn does the assert trigger with your patch so that > you have to remove it? Thanks for the review. Please find the attached patch this removes it and does the conversion as part of the GIMPLE_DEBUG. Does this look better? Thanks, Kugan gcc/ChangeLog: 2015-10-19 Kugan Vivekanandarajah * gimple-ssa-type-promote.c (fixup_uses): For GIMPLE_DEBUG stmts, convert the values computed in promoted_type to original and bind. > > + > + switch (TREE_CODE_CLASS (TREE_CODE (op))) > + { > + case tcc_exceptional: > + case tcc_unary: > + { > > Hmm. So when we promote _1 in > > _1 = ...; > # DEBUG i = _1 + 7; > > to sth else it would probably best to instead of doing conversion of operands > where necessary introduce a debug temporary like > > # DEBUG D#1 = (type-of-_1) replacement-of-_1; > > and replace debug uses of _1 with D#1 >From 47469bb461dcafdf0ce5fe5f020faed0e8d6d4d9 Mon Sep 17 00:00:00 2001 From: Kugan Vivekanandarajah Date: Tue, 1 Sep 2015 08:40:40 +1000 Subject: [PATCH 5/7] debug stmt in widen mode --- gcc/gimple-ssa-type-promote.c | 82 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 79 insertions(+), 3 deletions(-) diff --git a/gcc/gimple-ssa-type-promote.c b/gcc/gimple-ssa-type-promote.c index d4ca1a3..660bd3f 100644 --- a/gcc/gimple-ssa-type-promote.c +++ b/gcc/gimple-ssa-type-promote.c @@ -589,10 +589,86 @@ fixup_uses (tree use, tree promoted_type, tree old_type) { case GIMPLE_DEBUG: { - gsi = gsi_for_stmt (stmt); - gsi_remove (&gsi, true); - break; + /* Change the GIMPLE_DEBUG stmt such that the value bound is + computed in promoted_type and then converted to required + type. */ + tree op, new_op = NULL_TREE; + gdebug *copy = NULL, *gs = as_a (stmt); + enum tree_code code; + + /* Get the value that is bound in debug stmt. */ + switch (gs->subcode) + { + case GIMPLE_DEBUG_BIND: + op = gimple_debug_bind_get_value (gs); + break; + case GIMPLE_DEBUG_SOURCE_BIND: + op = gimple_debug_source_bind_get_value (gs); + break; + default: + gcc_unreachable (); + } + + code = TREE_CODE (op); + /* Convert the value computed in promoted_type to + old_type. */ + if (code == SSA_NAME && use == op) + new_op = build1 (NOP_EXPR, old_type, use); + else if (TREE_CODE_CLASS (TREE_CODE (op)) == tcc_unary + && code != NOP_EXPR) + { + tree op0 = TREE_OPERAND (op, 0); + if (op0 == use) + { + tree temp = build1 (code, promoted_type, op0); + new_op = build1 (NOP_EXPR, old_type, temp); + } + } + else if (TREE_CODE_CLASS (TREE_CODE (op)) == tcc_binary + /* Skip codes that are rejected in safe_to_promote_use_p. */ + && code != LROTATE_EXPR + && code != RROTATE_EXPR + && code != COMPLEX_EXPR) + { + tree op0 = TREE_OPERAND (op, 0); + tree op1 = TREE_OPERAND (op, 1); + if (op0 == use || op1 == use) + { + if (TREE_CODE (op0) == INTEGER_CST) + op0 = convert_int_cst (promoted_type, op0, SIGNED); + if (TREE_CODE (op1) == INTEGER_CST) + op1 = convert_int_cst (promoted_type, op1, SIGNED); + tree temp = build2 (code, promoted_type, op0, op1); + new_op = build1 (NOP_EXPR, old_type, temp); + } + } + + /* Create new GIMPLE_DEBUG stmt with the new value (new_op) to + be bound, if new value has been calculated */ + if (new_op) + { + if (gimple_debug_bind_p (stmt)) + { + copy = gimple_build_debug_bind + (gimple_debug_bind_get_var (stmt), + new_op, + stmt); + } + if (gimple_debug_source_bind_p (stmt)) + { + copy = gimple_build_debug_source_bind + (gimple_debug_source_bind_get_var (stmt), new_op, + stmt); + } + + if (copy) + { + gsi = gsi_for_stmt (stmt); + gsi_replace (&gsi, copy, false); + } + } } + break; case GIMPLE_ASM: case GIMPLE_CALL: -- 1.9.1