From patchwork Thu Oct 22 10:50:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kugan Vivekanandarajah X-Patchwork-Id: 55434 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 B3CE920581 for ; Thu, 22 Oct 2015 10:51:24 +0000 (UTC) Received: by lfaz124 with SMTP id z124sf30306338lfa.0 for ; Thu, 22 Oct 2015 03:51:23 -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=74bcAll20vJViXyqeTU6MIjAQjgXsNYe8CNNqOxIrF8=; b=cfdOWzEr06/RpbdG3nHHOPx68Y/yQsP3SZHTIBPVC87bsg9uupPXNd1BT8oQx8wk53 hWFUG0HsqR0uV8y5+i2VAggjweu8Xn2hAjVRyE5w2Y36WpdaYlZ+350BffL5CfgChUNQ /C7bAiOb57Ag8d1bYGQnm6E/X3Yn2lEq6H1lE/niAKPSnZGaZ6BbVjn2Umn9/p8h/1LG 2x6OuSKhbwOY10k5nngVmnQnRGo0XE7DWxi8NTVNGpvDUdtEe1aoETyhVWXbFRr4r7nu iMwfkflRh3JgcoXp9Gcap2EdPZ79FdRNJMi5gIuE1zHObIApxk/e9VVQb4hEon6gmab8 AZOw== X-Gm-Message-State: ALoCoQmNa3U/owDxyHROL3xWO6V4yU5tjLDSrjYoeNWZJjzL8XKW/CCH2ReOgxEtGs6r8Ad3MgOA X-Received: by 10.112.130.41 with SMTP id ob9mr3468565lbb.17.1445511083543; Thu, 22 Oct 2015 03:51:23 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.157.135 with SMTP id g129ls292221lfe.84.gmail; Thu, 22 Oct 2015 03:51:23 -0700 (PDT) X-Received: by 10.112.16.199 with SMTP id i7mr8048804lbd.105.1445511083377; Thu, 22 Oct 2015 03:51:23 -0700 (PDT) Received: from mail-lf0-x230.google.com (mail-lf0-x230.google.com. [2a00:1450:4010:c07::230]) by mx.google.com with ESMTPS id n187si9225223lfb.31.2015.10.22.03.51.23 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Oct 2015 03:51:23 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c07::230 as permitted sender) client-ip=2a00:1450:4010:c07::230; Received: by lffz202 with SMTP id z202so43146240lff.3 for ; Thu, 22 Oct 2015 03:51:23 -0700 (PDT) X-Received: by 10.112.129.202 with SMTP id ny10mr7868083lbb.112.1445511083154; Thu, 22 Oct 2015 03:51:23 -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 w3csp522017lbq; Thu, 22 Oct 2015 03:51:21 -0700 (PDT) X-Received: by 10.66.138.11 with SMTP id qm11mr16883966pab.126.1445511081081; Thu, 22 Oct 2015 03:51:21 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id z8si20207544pbt.196.2015.10.22.03.51.20 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Oct 2015 03:51:21 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-411008-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 59297 invoked by alias); 22 Oct 2015 10:51:04 -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 59282 invoked by uid 89); 22 Oct 2015 10:51:02 -0000 X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=AWL, BAYES_50, KAM_LOTSOFHASH, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f52.google.com Received: from mail-pa0-f52.google.com (HELO mail-pa0-f52.google.com) (209.85.220.52) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 22 Oct 2015 10:50:57 +0000 Received: by pasz6 with SMTP id z6so84120147pas.2 for ; Thu, 22 Oct 2015 03:50:55 -0700 (PDT) X-Received: by 10.68.244.34 with SMTP id xd2mr17000303pbc.0.1445511055064; Thu, 22 Oct 2015 03:50:55 -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 ro3sm13402149pbc.69.2015.10.22.03.50.52 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Oct 2015 03:50:54 -0700 (PDT) Subject: Re: [0/7] Type promotion pass and elimination of zext/sext To: Richard Biener References: <55ECFC2A.7050908@linaro.org> <56269E01.5010408@linaro.org> Cc: "gcc-patches@gcc.gnu.org" From: Kugan Message-ID: <5628BF86.6070503@linaro.org> Date: Thu, 22 Oct 2015 21:50:46 +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::230 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 On 21/10/15 23:45, Richard Biener wrote: > On Tue, Oct 20, 2015 at 10:03 PM, Kugan > wrote: >> >> >> On 07/09/15 12:53, Kugan wrote: >>> >>> This a new version of the patch posted in >>> https://gcc.gnu.org/ml/gcc-patches/2015-08/msg00226.html. I have done >>> more testing and spitted the patch to make it more easier to review. >>> There are still couple of issues to be addressed and I am working on them. >>> >>> 1. AARCH64 bootstrap now fails with the commit >>> 94f92c36a83d66a893c3bc6f00a038ba3dbe2a6f. simplify-rtx.c is mis-compiled >>> in stage2 and fwprop.c is failing. It looks to me that there is a latent >>> issue which gets exposed my patch. I can also reproduce this in x86_64 >>> if I use the same PROMOTE_MODE which is used in aarch64 port. For the >>> time being, I am using patch >>> 0006-temporary-workaround-for-bootstrap-failure-due-to-co.patch as a >>> workaround. This meeds to be fixed before the patches are ready to be >>> committed. >>> >>> 2. vector-compare-1.c from c-c++-common/torture fails to assemble with >>> -O3 -g Error: unaligned opcodes detected in executable segment. It works >>> fine if I remove the -g. I am looking into it and needs to be fixed as well. >> >> Hi Richard, >> >> Now that stage 1 is going to close, I would like to get these patches >> accepted for stage1. I will try my best to address your review comments >> ASAP. > > Ok, can you make the whole patch series available so I can poke at the > implementation a bit? Please state the revision it was rebased on > (or point me to a git/svn branch the work resides on). > Thanks. Please find the patched rebated against trunk@229156. I have skipped the test-case readjustment patches. Thanks, Kugan >From c0ce364e3a422912a08189645efde46c36583753 Mon Sep 17 00:00:00 2001 From: Kugan Vivekanandarajah Date: Thu, 22 Oct 2015 10:51:42 +1100 Subject: [PATCH 1/4] Add new SEXT_EXPR tree code --- gcc/cfgexpand.c | 12 ++++++++++++ gcc/expr.c | 20 ++++++++++++++++++++ gcc/fold-const.c | 4 ++++ gcc/tree-cfg.c | 12 ++++++++++++ gcc/tree-inline.c | 1 + gcc/tree-pretty-print.c | 11 +++++++++++ gcc/tree.def | 5 +++++ 7 files changed, 65 insertions(+) diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index eaad859..aeb64bb 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -5054,6 +5054,18 @@ expand_debug_expr (tree exp) case FMA_EXPR: return simplify_gen_ternary (FMA, mode, inner_mode, op0, op1, op2); + case SEXT_EXPR: + gcc_assert (CONST_INT_P (op1)); + inner_mode = mode_for_size (INTVAL (op1), MODE_INT, 0); + gcc_assert (GET_MODE_BITSIZE (inner_mode) == INTVAL (op1)); + + if (mode != inner_mode) + op0 = simplify_gen_unary (SIGN_EXTEND, + mode, + gen_lowpart_SUBREG (inner_mode, op0), + inner_mode); + return op0; + default: flag_unsupported: #ifdef ENABLE_CHECKING diff --git a/gcc/expr.c b/gcc/expr.c index da68870..c2f535f 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -9318,6 +9318,26 @@ expand_expr_real_2 (sepops ops, rtx target, machine_mode tmode, target = expand_vec_cond_expr (type, treeop0, treeop1, treeop2, target); return target; + case SEXT_EXPR: + { + machine_mode inner_mode = mode_for_size (tree_to_uhwi (treeop1), + MODE_INT, 0); + rtx temp, result; + rtx op0 = expand_normal (treeop0); + op0 = force_reg (mode, op0); + if (mode != inner_mode) + { + result = gen_reg_rtx (mode); + temp = simplify_gen_unary (SIGN_EXTEND, mode, + gen_lowpart_SUBREG (inner_mode, op0), + inner_mode); + convert_move (result, temp, 0); + } + else + result = op0; + return result; + } + default: gcc_unreachable (); } diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 602ea24..a149bad 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -987,6 +987,10 @@ int_const_binop_1 (enum tree_code code, const_tree arg1, const_tree parg2, res = wi::bit_and (arg1, arg2); break; + case SEXT_EXPR: + res = wi::sext (arg1, arg2.to_uhwi ()); + break; + case RSHIFT_EXPR: case LSHIFT_EXPR: if (wi::neg_p (arg2)) diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 8e3e810..d18b3f7 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -3752,6 +3752,18 @@ verify_gimple_assign_binary (gassign *stmt) return false; } + case SEXT_EXPR: + { + if (!INTEGRAL_TYPE_P (lhs_type) + || !useless_type_conversion_p (lhs_type, rhs1_type) + || !tree_fits_uhwi_p (rhs2)) + { + error ("invalid operands in sext expr"); + return true; + } + return false; + } + case VEC_WIDEN_LSHIFT_HI_EXPR: case VEC_WIDEN_LSHIFT_LO_EXPR: { diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index b8269ef..e61c200 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -3893,6 +3893,7 @@ estimate_operator_cost (enum tree_code code, eni_weights *weights, case BIT_XOR_EXPR: case BIT_AND_EXPR: case BIT_NOT_EXPR: + case SEXT_EXPR: case TRUTH_ANDIF_EXPR: case TRUTH_ORIF_EXPR: diff --git a/gcc/tree-pretty-print.c b/gcc/tree-pretty-print.c index 11f90051..bec9082 100644 --- a/gcc/tree-pretty-print.c +++ b/gcc/tree-pretty-print.c @@ -1923,6 +1923,14 @@ dump_generic_node (pretty_printer *pp, tree node, int spc, int flags, } break; + case SEXT_EXPR: + pp_string (pp, "SEXT_EXPR <"); + dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false); + pp_string (pp, ", "); + dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false); + pp_greater (pp); + break; + case MODIFY_EXPR: case INIT_EXPR: dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, @@ -3561,6 +3569,9 @@ op_symbol_code (enum tree_code code) case MIN_EXPR: return "min"; + case SEXT_EXPR: + return "sext"; + default: return "<<< ??? >>>"; } diff --git a/gcc/tree.def b/gcc/tree.def index d0a3bd6..789cfdd 100644 --- a/gcc/tree.def +++ b/gcc/tree.def @@ -760,6 +760,11 @@ DEFTREECODE (BIT_XOR_EXPR, "bit_xor_expr", tcc_binary, 2) DEFTREECODE (BIT_AND_EXPR, "bit_and_expr", tcc_binary, 2) DEFTREECODE (BIT_NOT_EXPR, "bit_not_expr", tcc_unary, 1) +/* Sign-extend operation. It will sign extend first operand from + the sign bit specified by the second operand. The type of the + result is that of the first operand. */ +DEFTREECODE (SEXT_EXPR, "sext_expr", tcc_binary, 2) + /* ANDIF and ORIF allow the second operand not to be computed if the value of the expression is determined from the first operand. AND, OR, and XOR always compute the second operand whether its value is -- 1.9.1