From patchwork Wed Apr 22 22:15:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kugan Vivekanandarajah X-Patchwork-Id: 47431 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3398320553 for ; Wed, 22 Apr 2015 22:15:56 +0000 (UTC) Received: by wicmx19 with SMTP id mx19sf15143701wic.3 for ; Wed, 22 Apr 2015 15:15:55 -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:message-id:date:from:user-agent:mime-version:to:cc :subject:references:in-reply-to:content-type:x-original-sender :x-original-authentication-results; bh=5/IFaOrERNs+8L1cqNqYy8FgIvRkFMUSo+199u0u6S4=; b=VYOmfi6QK1b0RbedNGjZejQ1M880ljrUjg7Qvje/UcwaZoRsY+zKFrljcHExW6hINW NwdKqR/yEgrVWCOSRfTYkJailfwNws3pkbF6OgAsiWHSEm+HVaXdMoqxVZDcCGMU52mz pq40xd3SXhyquJB851jE9Wl2hySOWQH9p3aEQXjXAWSOMnq+DAC+HdNONc0EkoaDMxso 88QncetozE2qHDIBifsv4PAi0qN+OCYfwlSU73C/9GrfU9rxFZjaAudp42iNxY35nnJr 2rxUdvOvwsX8VhZ8SCxeCoK6tszb0+moLIQrrGjbkBPW4YLe+NhzQfXMHSiXD37x/yCu bFjg== X-Gm-Message-State: ALoCoQm0YSSHVqMljoslEUvh+vVcSTI4Xi+md0yQWvomP9t0pLg2yJCUKLyeNQv+O+Hp23UzRXpU X-Received: by 10.152.184.73 with SMTP id es9mr12514803lac.4.1429740955514; Wed, 22 Apr 2015 15:15:55 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.227 with SMTP id t3ls270510laj.72.gmail; Wed, 22 Apr 2015 15:15:55 -0700 (PDT) X-Received: by 10.152.116.49 with SMTP id jt17mr18171261lab.82.1429740955374; Wed, 22 Apr 2015 15:15:55 -0700 (PDT) Received: from mail-lb0-x234.google.com (mail-lb0-x234.google.com. [2a00:1450:4010:c04::234]) by mx.google.com with ESMTPS id rb8si4673023lbb.34.2015.04.22.15.15.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Apr 2015 15:15:55 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::234 as permitted sender) client-ip=2a00:1450:4010:c04::234; Received: by lbbqq2 with SMTP id qq2so165058lbb.3 for ; Wed, 22 Apr 2015 15:15:55 -0700 (PDT) X-Received: by 10.112.163.168 with SMTP id yj8mr26498418lbb.36.1429740955246; Wed, 22 Apr 2015 15:15:55 -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.67.65 with SMTP id l1csp214507lbt; Wed, 22 Apr 2015 15:15:54 -0700 (PDT) X-Received: by 10.68.222.231 with SMTP id qp7mr11911362pbc.7.1429740953176; Wed, 22 Apr 2015 15:15:53 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id c1si9595157pde.169.2015.04.22.15.15.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Apr 2015 15:15:53 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-395827-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 11372 invoked by alias); 22 Apr 2015 22:15:37 -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 11359 invoked by uid 89); 22 Apr 2015 22:15:36 -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-f50.google.com Received: from mail-pa0-f50.google.com (HELO mail-pa0-f50.google.com) (209.85.220.50) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 22 Apr 2015 22:15:35 +0000 Received: by paboj16 with SMTP id oj16so334585pab.0 for ; Wed, 22 Apr 2015 15:15:33 -0700 (PDT) X-Received: by 10.70.49.35 with SMTP id r3mr39140641pdn.22.1429740933825; Wed, 22 Apr 2015 15:15:33 -0700 (PDT) Received: from [10.1.1.4] (58-6-183-210.dyn.iinet.net.au. [58.6.183.210]) by mx.google.com with ESMTPSA id nn6sm6040739pdb.79.2015.04.22.15.15.30 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Apr 2015 15:15:33 -0700 (PDT) Message-ID: <55381D7E.2000106@linaro.org> Date: Thu, 23 Apr 2015 08:15:26 +1000 From: Kugan User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Richard Biener , Jakub Jelinek , Jeff Law Subject: Re: [RFC][PATCH 3/3] Enable zero/sign extension elimination References: <54B9C2EE.4050100@linaro.org> <54B9C4CC.8070806@linaro.org> In-Reply-To: <54B9C4CC.8070806@linaro.org> 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:c04::234 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@gcc.gnu.org X-Google-Group-Id: 836684582541 On 17/01/15 13:11, Kugan wrote: > > Re-enable zero/sign extension elimination using value range that > includes wrapped attribute. > Now that stage-1 is open, rebased it and regression tested on x86-64-none-linux-gnu with no new regressions. Is this OK for trunk? Thanks, Kugan gcc/ChangeLog: 2015-04-22 Kugan Vivekanandarajah * calls.c (precompute_arguments): Check promoted_for_signed_and_unsigned_p and set the promoted mode. * expr.c (expand_expr_real_1): Likewise. (promoted_for_signed_and_unsigned_p): New function. * cfgexpand.c (expand_gimple_stmt_1): Call emit_move_insn if SUBREG is promoted with SRP_SIGNED_AND_UNSIGNED. * expr.h (promoted_for_signed_and_unsigned_p): New definition. diff --git a/gcc/calls.c b/gcc/calls.c index 3be7ca5..6b8d861 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -1637,7 +1637,10 @@ precompute_arguments (int num_actuals, struct arg_data *args) args[i].initial_value = gen_lowpart_SUBREG (mode, args[i].value); SUBREG_PROMOTED_VAR_P (args[i].initial_value) = 1; - SUBREG_PROMOTED_SET (args[i].initial_value, args[i].unsignedp); + if (promoted_for_signed_and_unsigned_p (args[i].tree_value)) + SUBREG_PROMOTED_SET (args[i].initial_value, SRP_SIGNED_AND_UNSIGNED); + else + SUBREG_PROMOTED_SET (args[i].initial_value, args[i].unsignedp); } } } diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index ca491a0..5fcee87 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -3452,7 +3452,13 @@ expand_gimple_stmt_1 (gimple stmt) GET_MODE (target), temp, unsignedp); } - convert_move (SUBREG_REG (target), temp, unsignedp); + if ((SUBREG_PROMOTED_GET (target) == SRP_SIGNED_AND_UNSIGNED) + && (GET_CODE (temp) == SUBREG) + && (GET_MODE (target) == GET_MODE (temp)) + && (GET_MODE (SUBREG_REG (target)) == GET_MODE (SUBREG_REG (temp)))) + emit_move_insn (SUBREG_REG (target), SUBREG_REG (temp)); + else + convert_move (SUBREG_REG (target), temp, unsignedp); } else if (nontemporal && emit_storent_insn (target, temp)) ; diff --git a/gcc/expr.c b/gcc/expr.c index 530a944..224a50f 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -185,6 +185,39 @@ static rtx const_vector_from_tree (tree); static tree tree_expr_size (const_tree); static HOST_WIDE_INT int_expr_size (tree); +/* Return TRUE if value in SSA is zero and sign extended for wider mode MODE + using value range information stored. Return FALSE otherwise. + + This is used to check if SUBREG is zero and sign extended and to set + promoted mode SRP_SIGNED_AND_UNSIGNED to SUBREG. */ + +bool +promoted_for_signed_and_unsigned_p (tree ssa) +{ + wide_int min, max; + bool ovf; + + if (ssa == NULL_TREE + || TREE_CODE (ssa) != SSA_NAME + || !INTEGRAL_TYPE_P (TREE_TYPE (ssa))) + return false; + + /* Return FALSE if value_range is not recorded for SSA. */ + if (get_range_info (ssa, &min, &max, &ovf) != VR_RANGE) + return false; + + if (ovf) + return false; + + /* Return true (to set SRP_SIGNED_AND_UNSIGNED to SUBREG) if MSB of the + smaller mode is not set (i.e. MSB of ssa is not set). */ + if (!wi::neg_p (min, SIGNED) && !wi::neg_p(max, SIGNED)) + return true; + else + return false; + +} + /* This is run to set up which modes can be used directly in memory and to initialize the block move optab. It is run @@ -9674,7 +9707,10 @@ expand_expr_real_1 (tree exp, rtx target, machine_mode tmode, temp = gen_lowpart_SUBREG (mode, decl_rtl); SUBREG_PROMOTED_VAR_P (temp) = 1; - SUBREG_PROMOTED_SET (temp, unsignedp); + if (promoted_for_signed_and_unsigned_p (ssa_name)) + SUBREG_PROMOTED_SET (temp, SRP_SIGNED_AND_UNSIGNED); + else + SUBREG_PROMOTED_SET (temp, unsignedp); return temp; } diff --git a/gcc/expr.h b/gcc/expr.h index 867852e..f965fe0 100644 --- a/gcc/expr.h +++ b/gcc/expr.h @@ -243,6 +243,7 @@ extern rtx expand_expr_real_1 (tree, rtx, machine_mode, enum expand_modifier, rtx *, bool); extern rtx expand_expr_real_2 (sepops, rtx, machine_mode, enum expand_modifier); +extern bool promoted_for_signed_and_unsigned_p (tree); /* Generate code for computing expression EXP. An rtx for the computed value is returned. The value is never null.