Make lambda vector and friends use HWI

Message ID alpine.LSU.2.20.1811081312520.1827@zhemvz.fhfr.qr
State New
Headers show
Series
  • Make lambda vector and friends use HWI
Related show

Commit Message

Richard Biener Nov. 8, 2018, 12:14 p.m.
This completes the transition to HWI for lamda vectors.  Previously
we propagated the HWI use of int_cst_value used throughout the dataref
code to local vars but left the actual lambda representation at int.
That's prone to overflows and silent wrong-code.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2018-11-08  Richard Biener  <rguenther@suse.de>

	* tree-data-ref.h (lambda_int): New typedef.
	(lambda_vector_gcd): Adjust.
	(lambda_vector_new): Likewise.
	(lambda_matrix_new): Likewise.

	* tree-data-ref.c  (print_lambda_vector): Adjust.

Patch

diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c
index 66e780d635a..6019c6168bf 100644
--- a/gcc/tree-data-ref.c
+++ b/gcc/tree-data-ref.c
@@ -393,7 +393,7 @@  print_lambda_vector (FILE * outfile, lambda_vector vector, int n)
   int i;
 
   for (i = 0; i < n; i++)
-    fprintf (outfile, "%3d ", vector[i]);
+    fprintf (outfile, "%3d ", (int)vector[i]);
   fprintf (outfile, "\n");
 }
 
diff --git a/gcc/tree-data-ref.h b/gcc/tree-data-ref.h
index 525d27f04b9..439a8b986dd 100644
--- a/gcc/tree-data-ref.h
+++ b/gcc/tree-data-ref.h
@@ -138,7 +138,8 @@  struct dr_alias
    space. A vector space is a set that is closed under vector addition
    and scalar multiplication.  In this vector space, an element is a list of
    integers.  */
-typedef int *lambda_vector;
+typedef HOST_WIDE_INT lambda_int;
+typedef lambda_int *lambda_vector;
 
 /* An integer matrix.  A matrix consists of m vectors of length n (IE
    all vectors are the same length).  */
@@ -611,11 +612,11 @@  void split_constant_offset (tree , tree *, tree *);
 
 /* Compute the greatest common divisor of a VECTOR of SIZE numbers.  */
 
-static inline int
+static inline lambda_int
 lambda_vector_gcd (lambda_vector vector, int size)
 {
   int i;
-  int gcd1 = 0;
+  lambda_int gcd1 = 0;
 
   if (size > 0)
     {
@@ -632,7 +633,7 @@  static inline lambda_vector
 lambda_vector_new (int size)
 {
   /* ???  We shouldn't abuse the GC allocator here.  */
-  return ggc_cleared_vec_alloc<int> (size);
+  return ggc_cleared_vec_alloc<lambda_int> (size);
 }
 
 /* Clear out vector VEC1 of length SIZE.  */
@@ -686,7 +687,7 @@  lambda_matrix_new (int m, int n, struct obstack *lambda_obstack)
   mat = XOBNEWVEC (lambda_obstack, lambda_vector, m);
 
   for (i = 0; i < m; i++)
-    mat[i] = XOBNEWVEC (lambda_obstack, int, n);
+    mat[i] = XOBNEWVEC (lambda_obstack, lambda_int, n);
 
   return mat;
 }