From patchwork Wed Apr 22 22:14:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kugan Vivekanandarajah X-Patchwork-Id: 47430 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8A53020553 for ; Wed, 22 Apr 2015 22:14:39 +0000 (UTC) Received: by lbbrr5 with SMTP id rr5sf36729lbb.3 for ; Wed, 22 Apr 2015 15:14:38 -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=EyOmCKAMTOCHmp4Rwj8fXxHQ74vYkxbn4B9+xOtBK9M=; b=cRsK0lwNSj11H8cdW8BkD8HhOXfZvRxh0Xq60lR81aLiU14SknkU69rtzsq42DW+0u NJlRRVb1mfQjo3kg5zDmhE8qtpOMymcK3oXx54elBZho7GjXEc1UniM/1P7RQhrYefoq BLoX0NARA0HrhF30L/IandT5M2w2ICCsDKL/KV0PdYyhPLXgKj2ocI46MImbakmIUiPY FzpiaxwyDPPtqA3fk+ssSq9t4hv/RTUP7GAPqRWc8k8XVaBIODoRriwyWCoxY8Bkb6k+ YeZjGZkOuEfObF02cSOEPqW1ixpPUjJsAgwXEsDM9HJ5o32KV9MY96SQctQ9hLz69Ke7 hj4w== X-Gm-Message-State: ALoCoQm7pQ/x8HmpeozP29tCCkRSzk8DDIoJHxR8h9cqG0Y1oF5+pnpnH3IGrAgqQRZ/cm1T7KMk X-Received: by 10.112.130.71 with SMTP id oc7mr12378807lbb.23.1429740878204; Wed, 22 Apr 2015 15:14:38 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.10.5 with SMTP id e5ls240276lab.37.gmail; Wed, 22 Apr 2015 15:14:38 -0700 (PDT) X-Received: by 10.112.225.43 with SMTP id rh11mr26503867lbc.90.1429740877987; Wed, 22 Apr 2015 15:14:37 -0700 (PDT) Received: from mail-la0-x231.google.com (mail-la0-x231.google.com. [2a00:1450:4010:c03::231]) by mx.google.com with ESMTPS id m4si4665400lbc.59.2015.04.22.15.14.37 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Apr 2015 15:14:37 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::231 as permitted sender) client-ip=2a00:1450:4010:c03::231; Received: by laat2 with SMTP id t2so178380laa.1 for ; Wed, 22 Apr 2015 15:14:37 -0700 (PDT) X-Received: by 10.112.125.138 with SMTP id mq10mr27068081lbb.35.1429740877815; Wed, 22 Apr 2015 15:14:37 -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 l1csp214011lbt; Wed, 22 Apr 2015 15:14:36 -0700 (PDT) X-Received: by 10.68.139.37 with SMTP id qv5mr3061476pbb.23.1429740875691; Wed, 22 Apr 2015 15:14:35 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id pp4si9592406pbb.58.2015.04.22.15.14.34 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Apr 2015 15:14:35 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-395826-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 9212 invoked by alias); 22 Apr 2015 22:14:21 -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 9106 invoked by uid 89); 22 Apr 2015 22:14:20 -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-pd0-f182.google.com Received: from mail-pd0-f182.google.com (HELO mail-pd0-f182.google.com) (209.85.192.182) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 22 Apr 2015 22:14:19 +0000 Received: by pdbqa5 with SMTP id qa5so292437pdb.1 for ; Wed, 22 Apr 2015 15:14:17 -0700 (PDT) X-Received: by 10.70.101.200 with SMTP id fi8mr32723891pdb.161.1429740857293; Wed, 22 Apr 2015 15:14:17 -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 l1sm3784521pdp.71.2015.04.22.15.14.14 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Apr 2015 15:14:16 -0700 (PDT) Message-ID: <55381D32.4060508@linaro.org> Date: Thu, 23 Apr 2015 08:14:10 +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 1/3] Free a bit in SSA_NAME to save wrapped information References: <54B9C2EE.4050100@linaro.org> <54B9C3C2.2020402@linaro.org> In-Reply-To: <54B9C3C2.2020402@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:c03::231 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:06, Kugan wrote: > Freeing a spare-bit to store wrapped attribute by going back to > representing VR_ANTI_RANGE as [max + 1, min - 1] in SSA_NAME. > 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 * tree-ssanames.c (set_range_info): Change range info representation and represent VR_ANTI_RANGE as [max + 1, min - 1]. (get_range_info): Likewise. (set_nonzero_bits): Likewise. (duplicate_ssa_name_range_info): Likewise. * tree-ssanames.h (set_range_info): Change prototype. (get_range_info): Likewise. (set_nonzero_bits): Likewise. (duplicate_ssa_name_range_info): Likewise. * tree-vrp.c (remove_range_assertions): Use new representation. (vrp_finalize): Likewise. * tree-ssa-pre.c (insert_into_preds_of_block): Likewise. diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c index d857d84..67e5351 100644 --- a/gcc/tree-ssa-pre.c +++ b/gcc/tree-ssa-pre.c @@ -3205,7 +3205,6 @@ insert_into_preds_of_block (basic_block block, unsigned int exprnum, && !wi::neg_p (max, SIGNED)) /* Just handle extension and sign-changes of all-positive ranges. */ set_range_info (temp, - SSA_NAME_RANGE_TYPE (expr->u.nary->op[0]), wide_int_storage::from (min, TYPE_PRECISION (type), TYPE_SIGN (type)), wide_int_storage::from (max, TYPE_PRECISION (type), diff --git a/gcc/tree-ssanames.c b/gcc/tree-ssanames.c index 9c39f65..744dc43 100644 --- a/gcc/tree-ssanames.c +++ b/gcc/tree-ssanames.c @@ -200,11 +200,10 @@ make_ssa_name_fn (struct function *fn, tree var, gimple stmt) /* Store range information RANGE_TYPE, MIN, and MAX to tree ssa_name NAME. */ void -set_range_info (tree name, enum value_range_type range_type, +set_range_info (tree name, const wide_int_ref &min, const wide_int_ref &max) { gcc_assert (!POINTER_TYPE_P (TREE_TYPE (name))); - gcc_assert (range_type == VR_RANGE || range_type == VR_ANTI_RANGE); range_info_def *ri = SSA_NAME_RANGE_INFO (name); unsigned int precision = TYPE_PRECISION (TREE_TYPE (name)); @@ -219,16 +218,12 @@ set_range_info (tree name, enum value_range_type range_type, ri->set_nonzero_bits (wi::shwi (-1, precision)); } - /* Record the range type. */ - if (SSA_NAME_RANGE_TYPE (name) != range_type) - SSA_NAME_ANTI_RANGE_P (name) = (range_type == VR_ANTI_RANGE); - /* Set the values. */ ri->set_min (min); ri->set_max (max); /* If it is a range, try to improve nonzero_bits from the min/max. */ - if (range_type == VR_RANGE) + if (wi::cmp (min, max, TYPE_SIGN (TREE_TYPE (name))) < 0) { wide_int xorv = ri->get_min () ^ ri->get_max (); if (xorv != 0) @@ -248,6 +243,7 @@ get_range_info (const_tree name, wide_int *min, wide_int *max) gcc_assert (!POINTER_TYPE_P (TREE_TYPE (name))); gcc_assert (min && max); range_info_def *ri = SSA_NAME_RANGE_INFO (name); + value_range_type range_type; /* Return VR_VARYING for SSA_NAMEs with NULL RANGE_INFO or SSA_NAMEs with integral types width > 2 * HOST_BITS_PER_WIDE_INT precision. */ @@ -255,9 +251,22 @@ get_range_info (const_tree name, wide_int *min, wide_int *max) > 2 * HOST_BITS_PER_WIDE_INT)) return VR_VARYING; - *min = ri->get_min (); - *max = ri->get_max (); - return SSA_NAME_RANGE_TYPE (name); + /* If max < min, it is VR_ANTI_RANGE. */ + if (wi::cmp (ri->get_max (), ri->get_min (), TYPE_SIGN (TREE_TYPE (name))) < 0) + { + /* VR_ANTI_RANGE ~[min, max] is encoded as [max + 1, min - 1]. */ + range_type = VR_ANTI_RANGE; + *min = wi::add (ri->get_max (), 1); + *max = wi::sub (ri->get_min (), 1); + } + else + { + /* Otherwise (when min <= max), it is VR_RANGE. */ + range_type = VR_RANGE; + *min = ri->get_min (); + *max = ri->get_max (); + } + return range_type; } /* Change non-zero bits bitmask of NAME. */ @@ -267,7 +276,7 @@ set_nonzero_bits (tree name, const wide_int_ref &mask) { gcc_assert (!POINTER_TYPE_P (TREE_TYPE (name))); if (SSA_NAME_RANGE_INFO (name) == NULL) - set_range_info (name, VR_RANGE, + set_range_info (name, TYPE_MIN_VALUE (TREE_TYPE (name)), TYPE_MAX_VALUE (TREE_TYPE (name))); range_info_def *ri = SSA_NAME_RANGE_INFO (name); @@ -495,7 +504,8 @@ duplicate_ssa_name_ptr_info (tree name, struct ptr_info_def *ptr_info) /* Creates a duplicate of the range_info_def at RANGE_INFO of type RANGE_TYPE for use by the SSA name NAME. */ void -duplicate_ssa_name_range_info (tree name, enum value_range_type range_type, +duplicate_ssa_name_range_info (tree name, + enum value_range_type range_type ATTRIBUTE_UNUSED, struct range_info_def *range_info) { struct range_info_def *new_range_info; @@ -513,8 +523,6 @@ duplicate_ssa_name_range_info (tree name, enum value_range_type range_type, new_range_info = static_cast (ggc_internal_alloc (size)); memcpy (new_range_info, range_info, size); - gcc_assert (range_type == VR_RANGE || range_type == VR_ANTI_RANGE); - SSA_NAME_ANTI_RANGE_P (name) = (range_type == VR_ANTI_RANGE); SSA_NAME_RANGE_INFO (name) = new_range_info; } diff --git a/gcc/tree-ssanames.h b/gcc/tree-ssanames.h index a7eeb8f..0d4b212 100644 --- a/gcc/tree-ssanames.h +++ b/gcc/tree-ssanames.h @@ -68,7 +68,7 @@ struct GTY ((variable_size)) range_info_def { enum value_range_type { VR_UNDEFINED, VR_RANGE, VR_ANTI_RANGE, VR_VARYING }; /* Sets the value range to SSA. */ -extern void set_range_info (tree, enum value_range_type, const wide_int_ref &, +extern void set_range_info (tree, const wide_int_ref &, const wide_int_ref &); /* Gets the value range from SSA. */ extern enum value_range_type get_range_info (const_tree, wide_int *, diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index e7ab23c..d823be9 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -6934,7 +6934,7 @@ remove_range_assertions (void) && all_imm_uses_in_stmt_or_feed_cond (var, stmt, single_pred (bb))) { - set_range_info (var, SSA_NAME_RANGE_TYPE (lhs), + set_range_info (var, SSA_NAME_RANGE_INFO (lhs)->get_min (), SSA_NAME_RANGE_INFO (lhs)->get_max ()); maybe_set_nonzero_bits (bb, var); @@ -10258,12 +10258,35 @@ vrp_finalize (void) || (vr_value[i]->type == VR_UNDEFINED)) continue; - if ((TREE_CODE (vr_value[i]->min) == INTEGER_CST) - && (TREE_CODE (vr_value[i]->max) == INTEGER_CST) - && (vr_value[i]->type == VR_RANGE - || vr_value[i]->type == VR_ANTI_RANGE)) - set_range_info (name, vr_value[i]->type, vr_value[i]->min, - vr_value[i]->max); + if ((TREE_CODE (vr_value[i]->min) == INTEGER_CST) + && (TREE_CODE (vr_value[i]->max) == INTEGER_CST) + && (vr_value[i]->type == VR_RANGE + || vr_value[i]->type == VR_ANTI_RANGE)) + { + if (vr_value[i]->type == VR_RANGE) + set_range_info (name, vr_value[i]->min, vr_value[i]->max); + else if (vr_value[i]->type == VR_ANTI_RANGE) + { + /* VR_ANTI_RANGE + ~[min, max] is encoded compactly as + [max + 1, min - 1] without additional attributes. + When min value > max value, we know that it is + VR_ANTI_RANGE; it is VR_RANGE otherwise. */ + + if (TYPE_UNSIGNED (TREE_TYPE (name)) + && integer_zerop (vr_value[i]->min) + && integer_zerop (vr_value[i]->max)) + /* ~[0,0] anti-range is represented as range. */ + set_range_info (name, + build_int_cst (TREE_TYPE (name), 1), + TYPE_MAXVAL (TREE_TYPE (name))); + else + set_range_info (name, + wi::add (vr_value[i]->max, 1), + wi::sub (vr_value[i]->min, 1)); + } + } + } /* Free allocated memory. */