summaryrefslogtreecommitdiff
path: root/gcc/graphite-clast-to-gimple.c
diff options
context:
space:
mode:
authorspop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>2011-07-21 22:57:49 +0000
committerspop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>2011-07-21 22:57:49 +0000
commite45543a044c82ce9f537ef8b3e5504c4d164e32d (patch)
treef1d9fd23a26747a21db1850b97aa3885e1eec681 /gcc/graphite-clast-to-gimple.c
parent7cfe5b1fd0130480190e0bc8771a103270e375c6 (diff)
downloadgcc-e45543a044c82ce9f537ef8b3e5504c4d164e32d.tar.gz
Generate signed types whenever possible.
2011-07-21 Sebastian Pop <sebastian.pop@amd.com> * graphite-clast-to-gimple.c (type_for_interval): Generate signed types whenever possible. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@176604 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/graphite-clast-to-gimple.c')
-rw-r--r--gcc/graphite-clast-to-gimple.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/gcc/graphite-clast-to-gimple.c b/gcc/graphite-clast-to-gimple.c
index 6bc84d2a4b2..9cd27372bb6 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)
{