From patchwork Thu Jun 26 02:47:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kugan Vivekanandarajah X-Patchwork-Id: 32514 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f72.google.com (mail-yh0-f72.google.com [209.85.213.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7FD60201EF for ; Thu, 26 Jun 2014 02:48:55 +0000 (UTC) Received: by mail-yh0-f72.google.com with SMTP id f10sf5587152yha.3 for ; Wed, 25 Jun 2014 19:48: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:x-original-sender :x-original-authentication-results:content-type; bh=YQ8jk3sknuU/s3BkkV0DKVGVmm9N0/3+HJQwmrwy+F0=; b=Zs6M4xJ2k53Z48YPKOYFVgAfR4dLW71fKYNA4T1WRgFKDLemTKgHk+DBw8oCWsGWov yVt4mQS4nUtUdbZrSCvnFzAs5ZyQQIySPijiejqvX8pLDHmbaj/GaWmSAHY/J9Yvi8xX k760fJey8+GsngfdF4NFakcG33nI2o42ZjXZk6h2BJsuuPVt1W68reiV1fOmBq1tQ1Ix xYNj4iLaKv4gzNW7xFnkFCr1ojMyJ4tEDYp/LYqT1KrgWPX1kObKVwOqxG91xH/Ahf15 AoDY+eT8UNTCITtKzf40vLrlNVco2zkXO4YbmfT5P/RW9oHSdJQnJ3yK/sy3a6dfPqBK 0gTg== X-Gm-Message-State: ALoCoQlPph5NewfPZQM0VLuxlenyVNU2gW1EfB+o75T5OQqaiqjpLiTAQeUPdbwG97ySUoKp7cYb X-Received: by 10.224.41.74 with SMTP id n10mr6349986qae.1.1403750935317; Wed, 25 Jun 2014 19:48:55 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.92.131 with SMTP id b3ls46192qge.29.gmail; Wed, 25 Jun 2014 19:48:55 -0700 (PDT) X-Received: by 10.220.69.72 with SMTP id y8mr10561229vci.21.1403750935235; Wed, 25 Jun 2014 19:48:55 -0700 (PDT) Received: from mail-ve0-x22f.google.com (mail-ve0-x22f.google.com [2607:f8b0:400c:c01::22f]) by mx.google.com with ESMTPS id or9si3550713vcb.81.2014.06.25.19.48.55 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 25 Jun 2014 19:48:55 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c01::22f as permitted sender) client-ip=2607:f8b0:400c:c01::22f; Received: by mail-ve0-f175.google.com with SMTP id jx11so2988864veb.20 for ; Wed, 25 Jun 2014 19:48:55 -0700 (PDT) X-Received: by 10.52.5.129 with SMTP id s1mr9016326vds.31.1403750935108; Wed, 25 Jun 2014 19:48: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.221.37.5 with SMTP id tc5csp334129vcb; Wed, 25 Jun 2014 19:48:54 -0700 (PDT) X-Received: by 10.66.65.169 with SMTP id y9mr16800405pas.145.1403750933998; Wed, 25 Jun 2014 19:48:53 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id df3si7804343pbc.99.2014.06.25.19.48.53 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Jun 2014 19:48:53 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-371166-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 9592 invoked by alias); 26 Jun 2014 02:48:36 -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 9472 invoked by uid 89); 26 Jun 2014 02:48:20 -0000 X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pd0-f172.google.com Received: from mail-pd0-f172.google.com (HELO mail-pd0-f172.google.com) (209.85.192.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 26 Jun 2014 02:48:03 +0000 Received: by mail-pd0-f172.google.com with SMTP id w10so2419868pde.17 for ; Wed, 25 Jun 2014 19:48:01 -0700 (PDT) X-Received: by 10.68.139.137 with SMTP id qy9mr17104763pbb.11.1403750881007; Wed, 25 Jun 2014 19:48:01 -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 bv4sm27012860pad.25.2014.06.25.19.47.58 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 25 Jun 2014 19:48:00 -0700 (PDT) Message-ID: <53AB89DB.1060708@linaro.org> Date: Thu, 26 Jun 2014 12:47:55 +1000 From: Kugan User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: Jakub Jelinek CC: Richard Henderson , "gcc-patches@gcc.gnu.org" Subject: Re: [PATCH 1/2] Enable setting sign and unsigned promoted mode (SPR_SIGNED_AND_UNSIGNED) References: <53A9658F.2070304@linaro.org> <53A96657.1030901@linaro.org> <20140624121812.GW31640@tucnak.redhat.com> <53AA7864.9020500@linaro.org> <20140625075005.GY31640@tucnak.redhat.com> <53AB7212.5080902@linaro.org> In-Reply-To: <53AB7212.5080902@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 2607:f8b0:400c:c01::22f 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 26/06/14 11:06, Kugan wrote: > On 25/06/14 17:50, Jakub Jelinek wrote: >> On Wed, Jun 25, 2014 at 05:21:08PM +1000, Kugan wrote: >>> The problem with SRP_POINTER 0, SRP_SIGNED 1, SRP_UNSIGNED 2, >>> SRP_SIGNED_AND_UNSIGNED 3 (as I understand) is that, it will be >>> incompatible with TYPE_UNSIGNED (tree) and defines of >>> POINTER_EXTEND_UNSIGNED values. We will have to then translate while >>> setting to SRP_* values . Also SUBREG_PROMOTED_SIGNED_P is now checked >>> in some cases for != 0 (meaning SRP_POINTER or SRP_UNSIGNED) and in some >>> cases > 0 (meaning SRP_UNSIGNED). >>> >>> Since our aim is to perform single bit checks, why don’t we just use >>> this representation internally (i.e. _rtx->unchanging = 1 if SRP_SIGNED >>> and _rtx->volatil = 1 if SRP_UNSIGNED). As for SUBREG_PROMOTED_SIGNED_P, >>> we still have to return -1 or 1 depending on SRP_POINTER or SRP_UNSIGNED. >> >> Why don't you make SUBREG_PROMOTED_UNSIGNED_P just return 0/1 (i.e. the >> single bit), and for places where it would like to match both >> SRP_UNSIGNED and SRP_POINTER use SUBREG_PROMOTED_GET () & SRP_UNSIGNED >> or so? > > If we use SUBREG_PROMOTED_GET () & SRP_UNSIGNED, we will miss > the case SRP_SIGNED_AND_UNSIGNED. Though this is not wrong, we might > miss some optimization opportunities here. We can however use > (SUBREG_PROMOTED_GET () != SRP_SIGNED) if you like this. Other option is > to define another macro that explicilty says some think like > SUBREG_PROMOTED_POINTER_OR_UNSIGNED_P. > >>> --- a/gcc/ifcvt.c >>> +++ b/gcc/ifcvt.c >>> @@ -1448,8 +1448,11 @@ noce_emit_cmove (struct noce_if_info *if_info, rtx x, enum rtx_code code, >>> || byte_vtrue != byte_vfalse >>> || (SUBREG_PROMOTED_VAR_P (vtrue) >>> != SUBREG_PROMOTED_VAR_P (vfalse)) >>> - || (SUBREG_PROMOTED_UNSIGNED_P (vtrue) >>> - != SUBREG_PROMOTED_UNSIGNED_P (vfalse))) >>> + || ((SUBREG_PROMOTED_UNSIGNED_P (vtrue) >>> + != SUBREG_PROMOTED_UNSIGNED_P (vfalse)) >>> + && (SUBREG_PROMOTED_SIGNED_P (vtrue) >>> + != SUBREG_PROMOTED_SIGNED_P (vfalse)))) >> >> Shouldn't this be SUBREG_PROMOTED_GET (vtrue) != SUBREG_PROMOTED_GET (vfalse) ? > > The reason why I checked like this to cover one side with > SRP_SIGNED_AND_UNSIGNED and other with SRP_SIGNED or SRP_UNSIGNED. If > we check SUBREG_PROMOTED_GET (vtrue) != SUBREG_PROMOTED_GET (vfalse) we > will miss that. > >>> + >>> +/* Predicate to check if RTX of SUBREG_PROMOTED_VAR_P() is promoted >>> + for UNSIGNED type. In case of SRP_POINTER, SUBREG_PROMOTED_UNSIGNED_P >>> + returns -1 as this is in most cases handled like unsigned extension, >>> + except for generating instructions where special code is emitted for >>> + (ptr_extend insns) on some architectures. */ >>> #define SUBREG_PROMOTED_UNSIGNED_P(RTX) \ >>> - ((RTL_FLAG_CHECK1 ("SUBREG_PROMOTED_UNSIGNED_P", (RTX), SUBREG)->volatil) \ >>> - ? -1 : (int) (RTX)->unchanging) >>> + ((((RTL_FLAG_CHECK1 ("SUBREG_PROMOTED_UNSIGNED_P", (RTX), SUBREG)->volatil)\ >>> + + (RTX)->unchanging) == 0) ? -1 : ((RTX)->volatil == 1)) >>> + >>> +/* Checks if RTX of SUBREG_PROMOTED_VAR_P() is promotd for given SIGN. */ >>> +#define SUBREG_CHECK_PROMOTED_SIGN(RTX, SIGN) \ >> >> Use space rather than tab. Also, why do we need this macro? >> Can't you just use SUBREG_PROMOTED_GET () == sign ? I mean, sign in that >> case is typically just 0 or 1. > > Again I wanted to cover SRP_SIGNED_AND_UNSIGNED as well in this case. > I tried SUBREG_PROMOTED_GET () & SRP_UNSIGNED based on what you suggested (patch attached). the testcases I have for zero/sign extension are working with this. Bootstrapped and regression tested for arm-none-linux-gnueabi. If this is OK with you I will do regression testing on x86_64 and AAcrh64. Thanks, Kugan gcc/ 2014-06-26 Kugan Vivekanandarajah * calls.c (precompute_arguments): Use new SUBREG_PROMOTED_SET instead of SUBREG_PROMOTED_UNSIGNED_SET (expand_call): Likewise. * cfgexpand.c (expand_gimple_stmt_1): Use SUBREG_PROMOTED_GET & SRP_UNSIGNED to get promoted mode. * combine.c (record_promoted_value): Skip > 0 comaprison with SUBREG_PROMOTED_UNSIGNED_P as it now returns only 0 or 1. * expr.c (convert_move): Use SUBREG_PROMOTED_GET & SRP_UNSIGNED instead of SUBREG_PROMOTED_UNSIGNED_P. (convert_modes): Likewise. (store_expr): Likewise. (expand_expr_real_1): Use new SUBREG_PROMOTED_SET instead of SUBREG_PROMOTED_UNSIGNED_SET. * function.c (assign_parm_setup_reg): Use new SUBREG_PROMOTED_SET instead of SUBREG_PROMOTED_UNSIGNED_SET. * ifcvt.c (noce_emit_cmove): Updated to use SUBREG_PROMOTED_GET. * internal-fn.c (ubsan_expand_si_overflow_mul_check): Use SUBREG_PROMOTED_SET instead of SUBREG_PROMOTED_UNSIGNED_SET. * optabs.c (widen_operand): Use new SUBREG_PROMOTED_GET instead of SUBREG_PROMOTED_UNSIGNED_P. * rtl.h (SUBREG_PROMOTED_UNSIGNED_SET): Remove. (SUBREG_PROMOTED_SET): New define. (SUBREG_PROMOTED_GET): Likewise. (SUBREG_PROMOTED_SIGNED_P): Likewise. (SUBREG_PROMOTED_UNSIGNED_P): Updated. * rtlanal.c (unsigned_reg_p): Use new SUBREG_PROMOTED_GET instead of SUBREG_PROMOTED_UNSIGNED_GET. (nonzero_bits1): Skip > 0 comaprison with the results as SUBREG_PROMOTED_UNSIGNED_P now returns only 0 or 1. (num_sign_bit_copies1): Use SUBREG_PROMOTED_SIGNED_P instead of !SUBREG_PROMOTED_UNSIGNED_P. * simplify-rtx.c (simplify_unary_operation_1): Use new SUBREG_PROMOTED_SIGNED_P instead of !SUBREG_PROMOTED_UNSIGNED_P. (simplify_subreg): Use new SUBREG_PROMOTED_SIGNED_P, SUBREG_PROMOTED_UNSIGNED_P and SUBREG_PROMOTED_SET instead of SUBREG_PROMOTED_UNSIGNED_P and SUBREG_PROMOTED_UNSIGNED_SET. diff --git a/gcc/calls.c b/gcc/calls.c index 78fe7d8..a3e6faa 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -1484,8 +1484,7 @@ 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_UNSIGNED_SET (args[i].initial_value, - args[i].unsignedp); + SUBREG_PROMOTED_SET (args[i].initial_value, args[i].unsignedp); } } } @@ -3365,7 +3364,7 @@ expand_call (tree exp, rtx target, int ignore) target = gen_rtx_SUBREG (TYPE_MODE (type), target, offset); SUBREG_PROMOTED_VAR_P (target) = 1; - SUBREG_PROMOTED_UNSIGNED_SET (target, unsignedp); + SUBREG_PROMOTED_SET (target, unsignedp); } /* If size of args is variable or this was a constructor call for a stack diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index e8cd87f..bab9645 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -3297,7 +3297,7 @@ expand_gimple_stmt_1 (gimple stmt) ; else if (promoted) { - int unsignedp = SUBREG_PROMOTED_UNSIGNED_P (target); + int unsignedp = SUBREG_PROMOTED_GET (target) & SRP_UNSIGNED; /* If TEMP is a VOIDmode constant, use convert_modes to make sure that we properly convert it. */ if (CONSTANT_P (temp) && GET_MODE (temp) == VOIDmode) diff --git a/gcc/combine.c b/gcc/combine.c index 4e7ef55..15ecf1a 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -12427,7 +12427,7 @@ record_promoted_value (rtx insn, rtx subreg) rsp = ®_stat[regno]; if (rsp->last_set == insn) { - if (SUBREG_PROMOTED_UNSIGNED_P (subreg) > 0) + if (SUBREG_PROMOTED_UNSIGNED_P (subreg)) rsp->last_set_nonzero_bits &= GET_MODE_MASK (mode); } diff --git a/gcc/expr.c b/gcc/expr.c index 512c024..4fea105 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -329,7 +329,7 @@ convert_move (rtx to, rtx from, int unsignedp) if (GET_CODE (from) == SUBREG && SUBREG_PROMOTED_VAR_P (from) && (GET_MODE_PRECISION (GET_MODE (SUBREG_REG (from))) >= GET_MODE_PRECISION (to_mode)) - && SUBREG_PROMOTED_UNSIGNED_P (from) == unsignedp) + && (SUBREG_PROMOTED_GET (from) & SRP_UNSIGNED) == unsignedp) from = gen_lowpart (to_mode, from), from_mode = to_mode; gcc_assert (GET_CODE (to) != SUBREG || !SUBREG_PROMOTED_VAR_P (to)); @@ -703,7 +703,7 @@ convert_modes (enum machine_mode mode, enum machine_mode oldmode, rtx x, int uns if (GET_CODE (x) == SUBREG && SUBREG_PROMOTED_VAR_P (x) && GET_MODE_SIZE (GET_MODE (SUBREG_REG (x))) >= GET_MODE_SIZE (mode) - && SUBREG_PROMOTED_UNSIGNED_P (x) == unsignedp) + && (SUBREG_PROMOTED_GET (x) & SRP_UNSIGNED) == unsignedp) x = gen_lowpart (mode, SUBREG_REG (x)); if (GET_MODE (x) != VOIDmode) @@ -5203,24 +5203,25 @@ store_expr (tree exp, rtx target, int call_param_p, bool nontemporal) == TYPE_PRECISION (TREE_TYPE (exp))) { if (TYPE_UNSIGNED (TREE_TYPE (exp)) - != SUBREG_PROMOTED_UNSIGNED_P (target)) + != (SUBREG_PROMOTED_GET (target) & SRP_UNSIGNED)) { /* Some types, e.g. Fortran's logical*4, won't have a signed version, so use the mode instead. */ tree ntype = (signed_or_unsigned_type_for - (SUBREG_PROMOTED_UNSIGNED_P (target), TREE_TYPE (exp))); + (SUBREG_PROMOTED_GET (target) & SRP_UNSIGNED, + TREE_TYPE (exp))); if (ntype == NULL) ntype = lang_hooks.types.type_for_mode (TYPE_MODE (TREE_TYPE (exp)), - SUBREG_PROMOTED_UNSIGNED_P (target)); + SUBREG_PROMOTED_GET (target) & SRP_UNSIGNED); exp = fold_convert_loc (loc, ntype, exp); } exp = fold_convert_loc (loc, lang_hooks.types.type_for_mode (GET_MODE (SUBREG_REG (target)), - SUBREG_PROMOTED_UNSIGNED_P (target)), + SUBREG_PROMOTED_GET (target) & SRP_UNSIGNED), exp); inner_target = SUBREG_REG (target); @@ -5234,14 +5235,14 @@ store_expr (tree exp, rtx target, int call_param_p, bool nontemporal) if (CONSTANT_P (temp) && GET_MODE (temp) == VOIDmode) { temp = convert_modes (GET_MODE (target), TYPE_MODE (TREE_TYPE (exp)), - temp, SUBREG_PROMOTED_UNSIGNED_P (target)); + temp, SUBREG_PROMOTED_GET (target) & SRP_UNSIGNED); temp = convert_modes (GET_MODE (SUBREG_REG (target)), GET_MODE (target), temp, - SUBREG_PROMOTED_UNSIGNED_P (target)); + SUBREG_PROMOTED_GET (target) & SRP_UNSIGNED); } convert_move (SUBREG_REG (target), temp, - SUBREG_PROMOTED_UNSIGNED_P (target)); + SUBREG_PROMOTED_GET (target) & SRP_UNSIGNED); return NULL_RTX; } @@ -9513,7 +9514,7 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode, temp = gen_lowpart_SUBREG (mode, decl_rtl); SUBREG_PROMOTED_VAR_P (temp) = 1; - SUBREG_PROMOTED_UNSIGNED_SET (temp, unsignedp); + SUBREG_PROMOTED_SET (temp, unsignedp); return temp; } diff --git a/gcc/function.c b/gcc/function.c index 441289e..9509622 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -3093,7 +3093,7 @@ assign_parm_setup_reg (struct assign_parm_data_all *all, tree parm, /* The argument is already sign/zero extended, so note it into the subreg. */ SUBREG_PROMOTED_VAR_P (tempreg) = 1; - SUBREG_PROMOTED_UNSIGNED_SET (tempreg, unsignedp); + SUBREG_PROMOTED_SET (tempreg, unsignedp); } /* TREE_USED gets set erroneously during expand_assignment. */ diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c index 816cdaa..b3788e2 100644 --- a/gcc/ifcvt.c +++ b/gcc/ifcvt.c @@ -1448,8 +1448,8 @@ noce_emit_cmove (struct noce_if_info *if_info, rtx x, enum rtx_code code, || byte_vtrue != byte_vfalse || (SUBREG_PROMOTED_VAR_P (vtrue) != SUBREG_PROMOTED_VAR_P (vfalse)) - || (SUBREG_PROMOTED_UNSIGNED_P (vtrue) - != SUBREG_PROMOTED_UNSIGNED_P (vfalse))) + || ((SUBREG_PROMOTED_GET (vtrue) & SRP_UNSIGNED) + != (SUBREG_PROMOTED_GET (vfalse) & SRP_UNSIGNED))) return NULL_RTX; promoted_target = gen_reg_rtx (GET_MODE (reg_vtrue)); @@ -1463,7 +1463,7 @@ noce_emit_cmove (struct noce_if_info *if_info, rtx x, enum rtx_code code, target = gen_rtx_SUBREG (GET_MODE (vtrue), promoted_target, byte_vtrue); SUBREG_PROMOTED_VAR_P (target) = SUBREG_PROMOTED_VAR_P (vtrue); - SUBREG_PROMOTED_UNSIGNED_SET (target, SUBREG_PROMOTED_UNSIGNED_P (vtrue)); + SUBREG_PROMOTED_SET (target, SUBREG_PROMOTED_GET (vtrue)); emit_move_insn (x, target); return x; } diff --git a/gcc/internal-fn.c b/gcc/internal-fn.c index 78f59d6..4e0b964 100644 --- a/gcc/internal-fn.c +++ b/gcc/internal-fn.c @@ -584,12 +584,12 @@ ubsan_expand_si_overflow_mul_check (gimple stmt) if (GET_CODE (lopart0) == SUBREG) { SUBREG_PROMOTED_VAR_P (lopart0) = 1; - SUBREG_PROMOTED_UNSIGNED_SET (lopart0, 0); + SUBREG_PROMOTED_SET (lopart0, 0); } if (GET_CODE (lopart1) == SUBREG) { SUBREG_PROMOTED_VAR_P (lopart1) = 1; - SUBREG_PROMOTED_UNSIGNED_SET (lopart1, 0); + SUBREG_PROMOTED_SET (lopart1, 0); } tree halfstype = build_nonstandard_integer_type (hprec, 0); ops.op0 = make_tree (halfstype, lopart0); diff --git a/gcc/optabs.c b/gcc/optabs.c index ca1c194..d9c57b2 100644 --- a/gcc/optabs.c +++ b/gcc/optabs.c @@ -368,7 +368,7 @@ widen_operand (rtx op, enum machine_mode mode, enum machine_mode oldmode, a promoted object differs from our extension. */ if (! no_extend || (GET_CODE (op) == SUBREG && SUBREG_PROMOTED_VAR_P (op) - && SUBREG_PROMOTED_UNSIGNED_P (op) == unsignedp)) + && (SUBREG_PROMOTED_GET (op) & SRP_UNSIGNED == unsignedp))) return convert_modes (mode, oldmode, op, unsignedp); /* If MODE is no wider than a single word, we return a lowpart or paradoxical diff --git a/gcc/rtl.h b/gcc/rtl.h index 6ec91a8..288a77a 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -1585,29 +1585,62 @@ get_full_set_src_cost (rtx x, struct full_rtx_costs *c) #define SUBREG_PROMOTED_VAR_P(RTX) \ (RTL_FLAG_CHECK1 ("SUBREG_PROMOTED", (RTX), SUBREG)->in_struct) -#define SUBREG_PROMOTED_UNSIGNED_SET(RTX, VAL) \ -do { \ - rtx const _rtx = RTL_FLAG_CHECK1 ("SUBREG_PROMOTED_UNSIGNED_SET", \ - (RTX), SUBREG); \ - if ((VAL) < 0) \ - _rtx->volatil = 1; \ - else { \ - _rtx->volatil = 0; \ - _rtx->unchanging = (VAL); \ - } \ -} while (0) - /* Valid for subregs which are SUBREG_PROMOTED_VAR_P(). In that case this gives the necessary extensions: - 0 - signed - 1 - normal unsigned + 0 - signed (SPR_SIGNED) + 1 - normal unsigned (SPR_UNSIGNED) + 2 - value is both sign and unsign extended for mode + (SPR_SIGNED_AND_UNSIGNED). -1 - pointer unsigned, which most often can be handled like unsigned extension, except for generating instructions where we need to - emit special code (ptr_extend insns) on some architectures. */ + emit special code (ptr_extend insns) on some architectures + (SPR_POINTER). */ + +const unsigned int SRP_POINTER = -1; +const unsigned int SRP_SIGNED = 0; +const unsigned int SRP_UNSIGNED = 1; +const unsigned int SRP_SIGNED_AND_UNSIGNED = 2; + +/* Sets promoted mode for SUBREG_PROMOTED_VAR_P(). */ +#define SUBREG_PROMOTED_SET(RTX, VAL) \ +do { \ + rtx const _rtx = RTL_FLAG_CHECK1 ("SUBREG_PROMOTED_SET", \ + (RTX), SUBREG); \ + switch ((VAL)) \ + { \ + case SRP_POINTER: \ + _rtx->volatil = 0; \ + _rtx->unchanging = 0; \ + break; \ + case SRP_SIGNED: \ + _rtx->volatil = 0; \ + _rtx->unchanging = 1; \ + break; \ + case SRP_UNSIGNED: \ + _rtx->volatil = 1; \ + _rtx->unchanging = 0; \ + break; \ + case SRP_SIGNED_AND_UNSIGNED: \ + _rtx->volatil = 1; \ + _rtx->unchanging = 1; \ + break; \ + } \ +} while (0) + +/* Gets promoted mode for SUBREG_PROMOTED_VAR_P(). */ +#define SUBREG_PROMOTED_GET(RTX) \ + (2 * (RTL_FLAG_CHECK1 ("SUBREG_PROMOTED_GET", (RTX), SUBREG)->volatil)\ + + (RTX)->unchanging - 1) + +/* Predicate to check if RTX of SUBREG_PROMOTED_VAR_P() is promoted + for SIGNED type. */ +#define SUBREG_PROMOTED_SIGNED_P(RTX) \ + (RTL_FLAG_CHECK1 ("SUBREG_PROMOTED_SIGNED_P", (RTX), SUBREG)->unchanging) +/* Predicate to check if RTX of SUBREG_PROMOTED_VAR_P() is promoted + for UNSIGNED type. */ #define SUBREG_PROMOTED_UNSIGNED_P(RTX) \ - ((RTL_FLAG_CHECK1 ("SUBREG_PROMOTED_UNSIGNED_P", (RTX), SUBREG)->volatil) \ - ? -1 : (int) (RTX)->unchanging) + (RTL_FLAG_CHECK1 ("SUBREG_PROMOTED_UNSIGNED_P", (RTX), SUBREG)->volatil) /* True if the subreg was generated by LRA for reload insns. Such subregs are valid only during LRA. */ diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c index 82cfc1bf..5c8132f 100644 --- a/gcc/rtlanal.c +++ b/gcc/rtlanal.c @@ -670,7 +670,7 @@ unsigned_reg_p (rtx op) return true; if (GET_CODE (op) == SUBREG - && SUBREG_PROMOTED_UNSIGNED_P (op)) + && (SUBREG_PROMOTED_GET (op) & SRP_UNSIGNED)) return true; return false; @@ -4309,7 +4309,7 @@ nonzero_bits1 (const_rtx x, enum machine_mode mode, const_rtx known_x, been zero-extended, we know that at least the high-order bits are zero, though others might be too. */ - if (SUBREG_PROMOTED_VAR_P (x) && SUBREG_PROMOTED_UNSIGNED_P (x) > 0) + if (SUBREG_PROMOTED_VAR_P (x) && SUBREG_PROMOTED_UNSIGNED_P (x)) nonzero = GET_MODE_MASK (GET_MODE (x)) & cached_nonzero_bits (SUBREG_REG (x), GET_MODE (x), known_x, known_mode, known_ret); @@ -4619,7 +4619,7 @@ num_sign_bit_copies1 (const_rtx x, enum machine_mode mode, const_rtx known_x, and we are looking at it in a wider mode, we know that at least the high-order bits are known to be sign bit copies. */ - if (SUBREG_PROMOTED_VAR_P (x) && ! SUBREG_PROMOTED_UNSIGNED_P (x)) + if (SUBREG_PROMOTED_VAR_P (x) && SUBREG_PROMOTED_SIGNED_P (x)) { num0 = cached_num_sign_bit_copies (SUBREG_REG (x), mode, known_x, known_mode, known_ret); diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index 181b56f..d2d6b5b 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -1352,7 +1352,7 @@ simplify_unary_operation_1 (enum rtx_code code, enum machine_mode mode, rtx op) target mode is the same as the variable's promotion. */ if (GET_CODE (op) == SUBREG && SUBREG_PROMOTED_VAR_P (op) - && ! SUBREG_PROMOTED_UNSIGNED_P (op) + && SUBREG_PROMOTED_SIGNED_P (op) && GET_MODE_SIZE (mode) <= GET_MODE_SIZE (GET_MODE (XEXP (op, 0)))) { temp = rtl_hooks.gen_lowpart_no_emit (mode, op); @@ -1419,7 +1419,7 @@ simplify_unary_operation_1 (enum rtx_code code, enum machine_mode mode, rtx op) target mode is the same as the variable's promotion. */ if (GET_CODE (op) == SUBREG && SUBREG_PROMOTED_VAR_P (op) - && SUBREG_PROMOTED_UNSIGNED_P (op) > 0 + && SUBREG_PROMOTED_UNSIGNED_P (op) && GET_MODE_SIZE (mode) <= GET_MODE_SIZE (GET_MODE (XEXP (op, 0)))) { temp = rtl_hooks.gen_lowpart_no_emit (mode, op); @@ -5587,7 +5587,8 @@ simplify_subreg (enum machine_mode outermode, rtx op, { newx = gen_rtx_SUBREG (outermode, SUBREG_REG (op), final_offset); if (SUBREG_PROMOTED_VAR_P (op) - && SUBREG_PROMOTED_UNSIGNED_P (op) >= 0 + && (SUBREG_PROMOTED_UNSIGNED_P (op) + || SUBREG_PROMOTED_SIGNED_P (op)) && GET_MODE_CLASS (outermode) == MODE_INT && IN_RANGE (GET_MODE_SIZE (outermode), GET_MODE_SIZE (innermode), @@ -5595,8 +5596,7 @@ simplify_subreg (enum machine_mode outermode, rtx op, && subreg_lowpart_p (newx)) { SUBREG_PROMOTED_VAR_P (newx) = 1; - SUBREG_PROMOTED_UNSIGNED_SET - (newx, SUBREG_PROMOTED_UNSIGNED_P (op)); + SUBREG_PROMOTED_SET (newx, SUBREG_PROMOTED_GET (op)); } return newx; }