diff mbox

[5/5] Remove the lambda framework and make -ftree-loop-linear an alias of -floop-interchange.

Message ID AANLkTikYgUyAzm+pmq-uAAkzOTDAHv0WB3YjLQA+7oTy@mail.gmail.com
State New
Headers show

Commit Message

Sebastian Pop Jan. 18, 2011, 4:28 p.m. UTC
On Tue, Jan 18, 2011 at 04:12, Richard Guenther <rguenther@suse.de> wrote:
> Hm.  gcd looks like it could go to a more general place.  Even if it
> doesn't exactly fit hwint.h IMHO moving it there makes more sense.
> Maybe somebody else has a better idea though.

Ok, I will amend the patch with:

From ffdce31ad01856d8c531d4eb50ff72d8b66331af Mon Sep 17 00:00:00 2001
From: Sebastian Pop <sebpop@gmail.com>
Date: Tue, 18 Jan 2011 10:24:58 -0600
Subject: [PATCH] fix

---
 gcc/hwint.h         |   29 +++++++++++++++++++++++++++++
 gcc/tree-data-ref.h |   29 -----------------------------
 2 files changed, 29 insertions(+), 29 deletions(-)

Comments

Joseph Myers Jan. 25, 2011, 11:09 p.m. UTC | #1
On Tue, 18 Jan 2011, Sebastian Pop wrote:

> --- a/gcc/hwint.h
> +++ b/gcc/hwint.h
> @@ -228,4 +228,33 @@ exact_log2 (unsigned HOST_WIDE_INT x)
> 
>  #endif /* GCC_VERSION >= 3004 */
> 
> +/* Compute the greatest common divisor of two numbers using
> +   Euclid's algorithm.  */
> +
> +static inline int
> +gcd (int a, int b)

If this function goes in hwint.h it should be working on HOST_WIDE_INT not 
int; hwint.h and hwint.c are for operations on HOST_WIDE_INT rather than a 
more general dumping ground for integer operations.

Users of these functions seem to vary in what types they pass in (int, 
unsigned int, HOST_WIDE_INT, etc.) - clearly the caller is responsible for 
ensuring that the values are representable in the type used.

> +  x = abs (a);
> +  y = abs (b);

In turn a suitable abs_hwi function will need to be used (with an 
assertion in abs_hwi that the most-negative value isn't passed in).

> +static inline int
> +least_common_multiple (int a, int b)
> +{
> +  return (abs (a) * abs (b) / gcd (a, b));

Apart from using HOST_WIDE_INT here, again a check against overflow would 
seem like a good idea.
Eric Botcazou Jan. 26, 2011, 11:37 a.m. UTC | #2
> From ffdce31ad01856d8c531d4eb50ff72d8b66331af Mon Sep 17 00:00:00 2001
> From: Sebastian Pop <sebpop@gmail.com>
> Date: Tue, 18 Jan 2011 10:24:58 -0600
> Subject: [PATCH] fix
>
> ---
>  gcc/hwint.h         |   29 +++++++++++++++++++++++++++++
>  gcc/tree-data-ref.h |   29 -----------------------------
>  2 files changed, 29 insertions(+), 29 deletions(-)

This breaks Ada bootstrap:

 -I../../src/gcc/../libdecnumber -I../../src/gcc/../libdecnumber/bid -I../libdecnumber   ../../src/gcc/ada/targext.c -o 
ada/targext.o
In file included from ../../src/gcc/system.h:254:0,
                 from ../../src/gcc/ada/targext.c:36:
../../src/gcc/hwint.h: In function 'gcd':
../../src/gcc/hwint.h:239:3: error: implicit declaration of function 'abs' 
[-Werror=implicit-function-declaration]
cc1: all warnings being treated as errors

make[3]: *** [ada/targext.o] Error 1
Richard Biener Jan. 26, 2011, 11:43 a.m. UTC | #3
On Wed, 26 Jan 2011, Eric Botcazou wrote:

> > From ffdce31ad01856d8c531d4eb50ff72d8b66331af Mon Sep 17 00:00:00 2001
> > From: Sebastian Pop <sebpop@gmail.com>
> > Date: Tue, 18 Jan 2011 10:24:58 -0600
> > Subject: [PATCH] fix
> >
> > ---
> >  gcc/hwint.h         |   29 +++++++++++++++++++++++++++++
> >  gcc/tree-data-ref.h |   29 -----------------------------
> >  2 files changed, 29 insertions(+), 29 deletions(-)
> 
> This breaks Ada bootstrap:
> 
>  -I../../src/gcc/../libdecnumber -I../../src/gcc/../libdecnumber/bid -I../libdecnumber   ../../src/gcc/ada/targext.c -o 
> ada/targext.o
> In file included from ../../src/gcc/system.h:254:0,
>                  from ../../src/gcc/ada/targext.c:36:
> ../../src/gcc/hwint.h: In function 'gcd':
> ../../src/gcc/hwint.h:239:3: error: implicit declaration of function 'abs' 
> [-Werror=implicit-function-declaration]
> cc1: all warnings being treated as errors
> 
> make[3]: *** [ada/targext.o] Error 1

I am testing and committing as obvious the following at the moment.

Richard.

2011-01-26  Richard Guenther  <rguenther@suse.de>

	PR bootstrap/47467
	* targext.c: Include config.h.
	* gcc-interface/Make-lang.in (ada/targext.o): Add $(CONFIG_H)
	dependency.

Index: gcc/ada/targext.c
===================================================================
*** gcc/ada/targext.c	(revision 169283)
--- gcc/ada/targext.c	(working copy)
***************
*** 33,38 ****
--- 33,39 ----
  /*  extension for object and executable files. It is used by the compiler,  */
  /*  binder and tools.                                                       */
  
+ #include "config.h"
  #include "system.h"
  #include "coretypes.h"
  #include "tm.h"
Eric Botcazou Jan. 26, 2011, 3:37 p.m. UTC | #4
> I am testing and committing as obvious the following at the moment.
>
> Richard.
>
> 2011-01-26  Richard Guenther  <rguenther@suse.de>
>
> 	PR bootstrap/47467
> 	* targext.c: Include config.h.
> 	* gcc-interface/Make-lang.in (ada/targext.o): Add $(CONFIG_H)
> 	dependency.

Thanks!
Jay Foad Jan. 27, 2011, 9:23 a.m. UTC | #5
On 25 January 2011 23:09, Joseph S. Myers <joseph@codesourcery.com> wrote:
> On Tue, 18 Jan 2011, Sebastian Pop wrote:
>> +static inline int
>> +least_common_multiple (int a, int b)
>> +{
>> +  return (abs (a) * abs (b) / gcd (a, b));
>
> Apart from using HOST_WIDE_INT here, again a check against overflow would
> seem like a good idea.

Probably better to write:

  return abs (a) / gcd (a, b) * abs (b);

to avoid spurious overflow of the intermediate result of the multiply.

Jay.
diff mbox

Patch

diff --git a/gcc/hwint.h b/gcc/hwint.h
index 8bd7c5e..1eadd45 100644
--- a/gcc/hwint.h
+++ b/gcc/hwint.h
@@ -228,4 +228,33 @@  exact_log2 (unsigned HOST_WIDE_INT x)

 #endif /* GCC_VERSION >= 3004 */

+/* Compute the greatest common divisor of two numbers using
+   Euclid's algorithm.  */
+
+static inline int
+gcd (int a, int b)
+{
+  int x, y, z;
+
+  x = abs (a);
+  y = abs (b);
+
+  while (x > 0)
+    {
+      z = y % x;
+      y = x;
+      x = z;
+    }
+
+  return y;
+}
+
+/* Compute the least common multiple of two numbers A and B .  */
+
+static inline int
+least_common_multiple (int a, int b)
+{
+  return (abs (a) * abs (b) / gcd (a, b));
+}
+
 #endif /* ! GCC_HWINT_H */
diff --git a/gcc/tree-data-ref.h b/gcc/tree-data-ref.h
index 3fd4f47..2e85677 100644
--- a/gcc/tree-data-ref.h
+++ b/gcc/tree-data-ref.h
@@ -674,35 +674,6 @@  DEF_VEC_ALLOC_P (rdgc, heap);
 DEF_VEC_P (bitmap);
 DEF_VEC_ALLOC_P (bitmap, heap);

-/* Compute the greatest common divisor of two numbers using
-   Euclid's algorithm.  */
-
-static inline int
-gcd (int a, int b)
-{
-  int x, y, z;
-
-  x = abs (a);
-  y = abs (b);
-
-  while (x > 0)
-    {
-      z = y % x;
-      y = x;
-      x = z;
-    }
-
-  return y;
-}
-
-/* Compute the least common multiple of two numbers A and B .  */
-
-static inline int
-least_common_multiple (int a, int b)
-{
-  return (abs (a) * abs (b) / gcd (a, b));
-}
-
 /* Compute the greatest common divisor of a VECTOR of SIZE numbers.  */

 static inline int