From patchwork Sat Jan 17 02:11:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kugan Vivekanandarajah X-Patchwork-Id: 43265 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 65689240BA for ; Sat, 17 Jan 2015 02:12:06 +0000 (UTC) Received: by mail-lb0-f198.google.com with SMTP id l4sf380533lbv.1 for ; Fri, 16 Jan 2015 18:12:05 -0800 (PST) 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=8tyruRKR1+gKNVaW7oRUss4InR53RPqncqTY3N5IIzk=; b=HVdkOUX1iAks0jRUq9M7Ul4ypbbLO6EuktqMz8zyw7jfUaCXL3va5WgUzSesGGnh7M t1W3D3C510VSLGsEgFqRRAxbgSf3SBYcwTu/7qLqrJdy36QoEuF72GPnhPcfdhd6rcGD gQBTekLfwU9v6I1wEezNbleXaLGOIYvf6Y5v6vC94jbrS/OIDo3B4gaiiqU0cNaS90gF rNDQB7zMHE33CmI+YZ8aBAwqLrVPK9BiCkRDAgZiuLui2L9fU0A+rVMQ7U15KROBr9ra 7R8EatjdrXaQ4nlRSgC5LQSmVKNPqt/F+FTXwCjRqPWTQseASEsgZvpqeKpHyEyKzQNK W09Q== X-Gm-Message-State: ALoCoQkC1S4Fsj9/xTMfpEd/gojFEFW77vumGmg3d4RzOUOg8Rn8QjoGv9DqyXI412mutEuj8xMU X-Received: by 10.180.7.226 with SMTP id m2mr780987wia.5.1421460725230; Fri, 16 Jan 2015 18:12:05 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.74 with SMTP id q10ls427482laq.43.gmail; Fri, 16 Jan 2015 18:12:05 -0800 (PST) X-Received: by 10.152.161.168 with SMTP id xt8mr18679187lab.35.1421460725067; Fri, 16 Jan 2015 18:12:05 -0800 (PST) Received: from mail-lb0-x232.google.com (mail-lb0-x232.google.com. [2a00:1450:4010:c04::232]) by mx.google.com with ESMTPS id g1si4425831lbd.126.2015.01.16.18.12.04 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 16 Jan 2015 18:12:04 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::232 as permitted sender) client-ip=2a00:1450:4010:c04::232; Received: by mail-lb0-f178.google.com with SMTP id u14so21155892lbd.9 for ; Fri, 16 Jan 2015 18:12:04 -0800 (PST) X-Received: by 10.152.197.5 with SMTP id iq5mr18649374lac.6.1421460724616; Fri, 16 Jan 2015 18:12:04 -0800 (PST) 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.9.200 with SMTP id c8csp485647lbb; Fri, 16 Jan 2015 18:12:03 -0800 (PST) X-Received: by 10.66.141.7 with SMTP id rk7mr5267512pab.15.1421460722209; Fri, 16 Jan 2015 18:12:02 -0800 (PST) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id sm10si7426075pab.239.2015.01.16.18.12.01 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Jan 2015 18:12:02 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-389689-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 11262 invoked by alias); 17 Jan 2015 02:11:47 -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 11210 invoked by uid 89); 17 Jan 2015 02:11:37 -0000 X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=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-SHA encrypted) ESMTPS; Sat, 17 Jan 2015 02:11:35 +0000 Received: by mail-pa0-f50.google.com with SMTP id bj1so27620103pad.9 for ; Fri, 16 Jan 2015 18:11:34 -0800 (PST) X-Received: by 10.68.130.103 with SMTP id od7mr26786224pbb.117.1421460694219; Fri, 16 Jan 2015 18:11:34 -0800 (PST) Received: from [192.168.1.6] ([112.134.156.250]) by mx.google.com with ESMTPSA id rr9sm5212235pbc.39.2015.01.16.18.11.31 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 16 Jan 2015 18:11:33 -0800 (PST) Message-ID: <54B9C4CC.8070806@linaro.org> Date: Sat, 17 Jan 2015 13:11:24 +1100 From: Kugan User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Richard Biener , Jakub Jelinek , Jeff Law Subject: [RFC][PATCH 3/3] Enable zero/sign extension elimination References: <54B9C2EE.4050100@linaro.org> In-Reply-To: <54B9C2EE.4050100@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::232 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 Re-enable zero/sign extension elimination using value range that includes wrapped attribute. Thanks, Kugan gcc/ChangeLog: 2015-01-16 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 36aa19f..71d2469 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -1620,7 +1620,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 8926e8f..39d52db 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -3410,7 +3410,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 fc22862..48a5d13 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -174,6 +174,39 @@ static void emit_single_push_insn (machine_mode, rtx, tree); static void do_tablejump (rtx, machine_mode, rtx, rtx, rtx, int); static rtx const_vector_from_tree (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 @@ -9656,7 +9689,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 a7638b8..8fb1339 100644 --- a/gcc/expr.h +++ b/gcc/expr.h @@ -288,6 +288,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.