Fix bootstrap on ia64 with old GCC version.

Message ID dadefbab-ee0e-c789-3435-f604a75d75c0@suse.cz
State New
Headers show
Series
  • Fix bootstrap on ia64 with old GCC version.
Related show

Commit Message

Martin Liška July 3, 2018, 5:22 p.m.
Hi.

In order to make GCC 4.1 happy and build current tip, we need to define
static constants out of a class definition.

Ready for trunk?
Thanks,
Martin

gcc/ChangeLog:

2018-07-03  Martin Liska  <mliska@suse.cz>

	* tree-switch-conversion.h (struct jump_table_cluster): Define
         constant values outside of class declaration.
---
  gcc/tree-switch-conversion.h | 9 +++++++--
  1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Jakub Jelinek July 3, 2018, 5:32 p.m. | #1
On Tue, Jul 03, 2018 at 07:22:19PM +0200, Martin Liška wrote:
> In order to make GCC 4.1 happy and build current tip, we need to define

> static constants out of a class definition.

> 

> Ready for trunk?

> Thanks,

> Martin

> 

> gcc/ChangeLog:

> 

> 2018-07-03  Martin Liska  <mliska@suse.cz>

> 

> 	* tree-switch-conversion.h (struct jump_table_cluster): Define

>         constant values outside of class declaration.


That looks incorrect.  I don't see why 4.1 wouldn't allow the const static
data members initializers inside of the class.

You just need to define those vars, and the definition (without the
initializers) shouldn't go into the header, but to a single .c file instead
(I know right now there is just one .c file that includes this header, but
if we ever want to include it in more than one, it would be a problem;
if we never want to include in more than one, the question is why we have
the header file at all).

So IMHO keep tree-switch-conversion.h unmodified and add:

const unsigned HOST_WIDE_INT jump_table_cluster::max_ratio_for_size;
const unsigned HOST_WIDE_INT jump_table_cluster::max_ratio_for_speed;

to tree-switch-conversion.c somewhere.

> diff --git a/gcc/tree-switch-conversion.h b/gcc/tree-switch-conversion.h

> index 4beac785f05..8efb125aff1 100644

> --- a/gcc/tree-switch-conversion.h

> +++ b/gcc/tree-switch-conversion.h

> @@ -259,12 +259,17 @@ struct jump_table_cluster: public group_cluster

>    static bool is_enabled (void);

>  

>    /* Max growth ratio for code that is optimized for size.  */

> -  static const unsigned HOST_WIDE_INT max_ratio_for_size = 3;

> +  static const unsigned HOST_WIDE_INT max_ratio_for_size;

>  

>    /* Max growth ratio for code that is optimized for speed.  */

> -  static const unsigned HOST_WIDE_INT max_ratio_for_speed = 8;

> +  static const unsigned HOST_WIDE_INT max_ratio_for_speed;

>  };

>  

> +const unsigned HOST_WIDE_INT jump_table_cluster::max_ratio_for_size = 3;

> +

> +const unsigned HOST_WIDE_INT jump_table_cluster::max_ratio_for_speed = 8;

> +

> +

>  /* A GIMPLE switch statement can be expanded to a short sequence of bit-wise

>  comparisons.  "switch(x)" is converted into "if ((1 << (x-MINVAL)) & CST)"

>  where CST and MINVAL are integer constants.  This is better than a series

> 



	Jakub
Martin Liška July 4, 2018, 7:52 a.m. | #2
On 07/03/2018 07:32 PM, Jakub Jelinek wrote:
> On Tue, Jul 03, 2018 at 07:22:19PM +0200, Martin Liška wrote:

>> In order to make GCC 4.1 happy and build current tip, we need to define

>> static constants out of a class definition.

>>

>> Ready for trunk?

>> Thanks,

>> Martin

>>

>> gcc/ChangeLog:

>>

>> 2018-07-03  Martin Liska  <mliska@suse.cz>

>>

>> 	* tree-switch-conversion.h (struct jump_table_cluster): Define

>>         constant values outside of class declaration.

> 

> That looks incorrect.  I don't see why 4.1 wouldn't allow the const static

> data members initializers inside of the class.

> 

> You just need to define those vars, and the definition (without the

> initializers) shouldn't go into the header, but to a single .c file instead

> (I know right now there is just one .c file that includes this header, but

> if we ever want to include it in more than one, it would be a problem;

> if we never want to include in more than one, the question is why we have

> the header file at all).

> 

> So IMHO keep tree-switch-conversion.h unmodified and add:

> 

> const unsigned HOST_WIDE_INT jump_table_cluster::max_ratio_for_size;

> const unsigned HOST_WIDE_INT jump_table_cluster::max_ratio_for_speed;

> 

> to tree-switch-conversion.c somewhere.


Hi.

Thanks Jakub, works for me both on x86_64 with a recent compiler and
ia64 with GCC 4.1.

I'm going to install that.

Martin

> 

>> diff --git a/gcc/tree-switch-conversion.h b/gcc/tree-switch-conversion.h

>> index 4beac785f05..8efb125aff1 100644

>> --- a/gcc/tree-switch-conversion.h

>> +++ b/gcc/tree-switch-conversion.h

>> @@ -259,12 +259,17 @@ struct jump_table_cluster: public group_cluster

>>    static bool is_enabled (void);

>>  

>>    /* Max growth ratio for code that is optimized for size.  */

>> -  static const unsigned HOST_WIDE_INT max_ratio_for_size = 3;

>> +  static const unsigned HOST_WIDE_INT max_ratio_for_size;

>>  

>>    /* Max growth ratio for code that is optimized for speed.  */

>> -  static const unsigned HOST_WIDE_INT max_ratio_for_speed = 8;

>> +  static const unsigned HOST_WIDE_INT max_ratio_for_speed;

>>  };

>>  

>> +const unsigned HOST_WIDE_INT jump_table_cluster::max_ratio_for_size = 3;

>> +

>> +const unsigned HOST_WIDE_INT jump_table_cluster::max_ratio_for_speed = 8;

>> +

>> +

>>  /* A GIMPLE switch statement can be expanded to a short sequence of bit-wise

>>  comparisons.  "switch(x)" is converted into "if ((1 << (x-MINVAL)) & CST)"

>>  where CST and MINVAL are integer constants.  This is better than a series

>>

> 

> 

> 	Jakub

>

Patch

diff --git a/gcc/tree-switch-conversion.h b/gcc/tree-switch-conversion.h
index 4beac785f05..8efb125aff1 100644
--- a/gcc/tree-switch-conversion.h
+++ b/gcc/tree-switch-conversion.h
@@ -259,12 +259,17 @@  struct jump_table_cluster: public group_cluster
   static bool is_enabled (void);
 
   /* Max growth ratio for code that is optimized for size.  */
-  static const unsigned HOST_WIDE_INT max_ratio_for_size = 3;
+  static const unsigned HOST_WIDE_INT max_ratio_for_size;
 
   /* Max growth ratio for code that is optimized for speed.  */
-  static const unsigned HOST_WIDE_INT max_ratio_for_speed = 8;
+  static const unsigned HOST_WIDE_INT max_ratio_for_speed;
 };
 
+const unsigned HOST_WIDE_INT jump_table_cluster::max_ratio_for_size = 3;
+
+const unsigned HOST_WIDE_INT jump_table_cluster::max_ratio_for_speed = 8;
+
+
 /* A GIMPLE switch statement can be expanded to a short sequence of bit-wise
 comparisons.  "switch(x)" is converted into "if ((1 << (x-MINVAL)) & CST)"
 where CST and MINVAL are integer constants.  This is better than a series