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: 430087 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id F2DC9140077 for ; Sat, 17 Jan 2015 13:11:56 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; q=dns; s=default; b=EXou9uhs1s8d37fOr /j8EIp15PFofrptKbq7oEXwKRDbpD5+jGlBXmvfKCY6lFmeYgFLD2MpWK480pu8q gmp71qhcgRNeG5jYJeVgSPAu+9OmVXUVoDahG6vQNkqHuDEJ7oQUpBjDsx7dXYg7 0VTt/u2Prr6uYkfMpDzKW4dayE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; s=default; bh=XgjeJkA75S3Rg1SKSLa6Lez 5394=; b=IBri6hwjR5ex5Kbtm9RFq8ZNCT8yBOPwTDSJl370pIaFAeW+1sTQNEQ Iq8HlSAJD5gXZK3bXOMDV40b29Ean/IzmtIWk7rnMcUjGTHKP/zJXC1pmG3wfQJz amYZMjdxCTC6ldGVPodTWWjH1Ll8uQ7aGnQN22HjO4LBUUmKBWhc= Received: (qmail 11262 invoked by alias); 17 Jan 2015 02:11:47 -0000 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 Received: (qmail 11210 invoked by uid 89); 17 Jan 2015 02:11:37 -0000 Authentication-Results: sourceware.org; auth=none 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-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type; bh=8tyruRKR1+gKNVaW7oRUss4InR53RPqncqTY3N5IIzk=; b=ApFQU1rNXH212bJT/j/uxNB1EJVBmcKXWJOYq5cKuz+k+gA7sRzmN/T3YOKBPEDDiZ CmCPk/QuR4VSzDHrGDQmjq9E8iqgVv47mNQUXvjGjim6f929p9DozSNi6MzQBfN0ir7u cGFAj6YGo21DoKNMJ5MqvuWSn+j8S6fSg/PYSl//KnNr1cucR1nTXRRn4rVkblOTS5oB jdFyYlzry8OVFJLC9fPF2pvxZ8UVBJNq6jPxmVT+JAmoIM3+b4AUWy3YIh2uih59yFbF 1w4kaAGm+SpmMetdq0Ip1EkJMbSSowjxR3zG6cbRmr5yY23NX6nTRZDXm0PYl52AnnFR vECw== X-Gm-Message-State: ALoCoQljPuVfT+fO3Q0ypyergwJelaaabcjxohF2bgC82Xd+8FFOCl4pDyemW3+uJMpBvmIg29uT 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 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.