From patchwork Thu Jul 21 18:31:09 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Pop X-Patchwork-Id: 106134 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]) by ozlabs.org (Postfix) with SMTP id 8B1F1B6F71 for ; Fri, 22 Jul 2011 04:32:16 +1000 (EST) Received: (qmail 21447 invoked by alias); 21 Jul 2011 18:32:01 -0000 Received: (qmail 21342 invoked by uid 22791); 21 Jul 2011 18:31:59 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-gx0-f175.google.com (HELO mail-gx0-f175.google.com) (209.85.161.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 21 Jul 2011 18:31:44 +0000 Received: by gxk3 with SMTP id 3so885484gxk.20 for ; Thu, 21 Jul 2011 11:31:44 -0700 (PDT) Received: by 10.236.123.132 with SMTP id v4mr900465yhh.509.1311273104103; Thu, 21 Jul 2011 11:31:44 -0700 (PDT) Received: from napoca (adsl-99-184-92-236.dsl.austtx.sbcglobal.net [99.184.92.236]) by mx.google.com with ESMTPS id o47sm1364746yhn.58.2011.07.21.11.31.42 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 21 Jul 2011 11:31:43 -0700 (PDT) Received: by napoca (sSMTP sendmail emulation); Thu, 21 Jul 2011 13:31:41 -0500 From: Sebastian Pop To: gcc-patches@gcc.gnu.org Cc: rguenther@suse.de, tobias@grosser.es, Sebastian Pop Subject: [PATCH 09/10] Generate signed types whenever possible. Date: Thu, 21 Jul 2011 13:31:09 -0500 Message-Id: <1311273070-12128-10-git-send-email-sebpop@gmail.com> In-Reply-To: <1311273070-12128-1-git-send-email-sebpop@gmail.com> References: <1311273070-12128-1-git-send-email-sebpop@gmail.com> X-IsSubscribed: yes 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 2011-07-21 Sebastian Pop * graphite-clast-to-gimple.c (type_for_interval): Generate signed types whenever possible. --- gcc/ChangeLog | 5 +++++ gcc/graphite-clast-to-gimple.c | 13 +++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 485afca..c79f0b4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2011-07-21 Sebastian Pop + * graphite-clast-to-gimple.c (type_for_interval): Generate signed + types whenever possible. + +2011-07-21 Sebastian Pop + * graphite-clast-to-gimple.c (struct clast_name_index): Add lb and ub fields. (new_clast_name_index): Add lb and ub parameters. diff --git a/gcc/graphite-clast-to-gimple.c b/gcc/graphite-clast-to-gimple.c index 6bc84d2..9cd2737 100644 --- a/gcc/graphite-clast-to-gimple.c +++ b/gcc/graphite-clast-to-gimple.c @@ -443,6 +443,7 @@ type_for_interval (mpz_t v1, mpz_t v2) bool unsigned_p; tree type; enum machine_mode mode; + int wider_precision; int precision = MAX (mpz_sizeinbase (v1, 2), mpz_sizeinbase (v2, 2)); @@ -458,8 +459,16 @@ type_for_interval (mpz_t v1, mpz_t v2) unsigned_p = (mpz_sgn (v2) >= 0); mode = smallest_mode_for_size (precision, MODE_INT); - precision = GET_MODE_PRECISION (mode); - type = build_nonstandard_integer_type (precision, unsigned_p); + wider_precision = GET_MODE_PRECISION (mode); + + /* As we want to generate signed types as much as possible, try to + fit the interval [v1, v2] in a signed type. For example, + supposing that we have the interval [0, 100], instead of + generating unsigned char, we want to generate a signed char. */ + if (unsigned_p && precision < wider_precision) + unsigned_p = false; + + type = build_nonstandard_integer_type (wider_precision, unsigned_p); if (!type) {