[PATCH] c++ify sreal
From: Trevor Saunders Hi, do $subject, and cleanup for always 64 bit hwi. bootstrapped + regtested x86_64-unknown-linux-gnu, ok? Trev gcc/ChangeLog: 2014-10-24 Trevor Saunders * ipa-inline.c (edge_badness): Adjust. (inline_small_functions): Likewise. * predict.c (propagate_freq): Likewise. (estimate_bb_frequencies): Likewise. * sreal.c (sreal::dump): Rename from dump_sreal. (debug): Adjust. (copy): Remove function. (sreal::shift_right): Rename from sreal_sift_right. (sreal::normalize): Rename from normalize. (sreal_init): Remove function. (sreal::to_int): Rename from sreal_to_int. (sreal_compare): Remove function. (sreal::operator+): Rename from sreal_add. (sreal::operator-): Rename from sreal_sub. (sreal::operator*): Rename from sreal_mul. (sreal::operator/): Rename from sreal_div. * sreal.h (class sreal): Adjust. (inline sreal &operator+=): New operator. (inline sreal &operator-=): Likewise. (inline sreal &operator/=): Likewise. (inline sreal &operator*=): Likewise. (inline bool operator!=): Likewise. (inline bool operator>): Likewise. (inline bool operator<=): Likewise. (inline bool operator>=): Likewise. --- gcc/ipa-inline.c | 25 ++- gcc/predict.c| 82 -- gcc/sreal.c | 479 +++ gcc/sreal.h | 97 --- 4 files changed, 213 insertions(+), 470 deletions(-) diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c index e79a4dd..cca1fb3 100644 --- a/gcc/ipa-inline.c +++ b/gcc/ipa-inline.c @@ -939,29 +939,28 @@ edge_badness (struct cgraph_edge *edge, bool dump) else if (max_count) { - sreal tmp, relbenefit_real, growth_real; int relbenefit = relative_time_benefit (callee_info, edge, edge_time); /* Capping edge->count to max_count. edge->count can be larger than max_count if an inline adds new edges which increase max_count after max_count is computed. */ gcov_type edge_count = edge->count > max_count ? max_count : edge->count; - sreal_init (&relbenefit_real, relbenefit, 0); - sreal_init (&growth_real, growth, 0); + sreal relbenefit_real (relbenefit, 0); + sreal growth_real (growth, 0); /* relative_edge_count. */ - sreal_init (&tmp, edge_count, 0); - sreal_div (&tmp, &tmp, &max_count_real); + sreal tmp (edge_count, 0); + tmp /= max_count_real; /* relative_time_benefit. */ - sreal_mul (&tmp, &tmp, &relbenefit_real); - sreal_div (&tmp, &tmp, &max_relbenefit_real); + tmp *= relbenefit_real; + tmp /= max_relbenefit_real; /* growth_f_caller. */ - sreal_mul (&tmp, &tmp, &half_int_min_real); - sreal_div (&tmp, &tmp, &growth_real); + tmp *= half_int_min_real; + tmp /= growth_real; - badness = -1 * sreal_to_int (&tmp); + badness = -1 * tmp.to_int (); if (dump) { @@ -1604,9 +1603,9 @@ inline_small_functions (void) if (max_count < edge->count) max_count = edge->count; } - sreal_init (&max_count_real, max_count, 0); - sreal_init (&max_relbenefit_real, RELATIVE_TIME_BENEFIT_RANGE, 0); - sreal_init (&half_int_min_real, INT_MAX / 2, 0); + max_count_real = sreal (max_count, 0); + max_relbenefit_real = sreal (RELATIVE_TIME_BENEFIT_RANGE, 0); + half_int_min_real = sreal (INT_MAX / 2, 0); ipa_free_postorder_info (); initialize_growth_caches (); diff --git a/gcc/predict.c b/gcc/predict.c index 5f5d4a5..10675c3 100644 --- a/gcc/predict.c +++ b/gcc/predict.c @@ -2571,15 +2571,13 @@ propagate_freq (basic_block head, bitmap tovisit) bb->count = bb->frequency = 0; } - memcpy (&BLOCK_INFO (head)->frequency, &real_one, sizeof (real_one)); + BLOCK_INFO (head)->frequency = real_one; last = head; for (bb = head; bb; bb = nextbb) { edge_iterator ei; - sreal cyclic_probability, frequency; - - memcpy (&cyclic_probability, &real_zero, sizeof (real_zero)); - memcpy (&frequency, &real_zero, sizeof (real_zero)); + sreal cyclic_probability = real_zero; + sreal frequency = real_zero; nextbb = BLOCK_INFO (bb)->next; BLOCK_INFO (bb)->next = NULL; @@ -2596,42 +2594,34 @@ propagate_freq (basic_block head, bitmap tovisit) FOR_EACH_EDGE (e, ei, bb->preds) if (EDGE_INFO (e)->back_edge) { - sreal_add (&cyclic_probability, &cyclic_probability, - &EDGE_INFO (e)->back_edge_prob); + cyclic_probability += EDGE_INFO (e)->back_edge_prob; } else if (!(e->flags & EDGE_DFS_BACK)) { - sreal tmp; - /* frequency += (e->probability * BLOCK_INFO (e->src)->frequency /
Re: [PATCH] c++ify sreal
On Fri, Oct 24, 2014 at 8:28 AM, wrote: > From: Trevor Saunders > > Hi, > > do $subject, and cleanup for always 64 bit hwi. > > > bootstrapped + regtested x86_64-unknown-linux-gnu, ok? Ok. Can you please replace remaining HOST_WIDE_INT vestiges in there with [u]int64_t please? Thanks, Richard. > Trev > > gcc/ChangeLog: > > 2014-10-24 Trevor Saunders > > * ipa-inline.c (edge_badness): Adjust. > (inline_small_functions): Likewise. > * predict.c (propagate_freq): Likewise. > (estimate_bb_frequencies): Likewise. > * sreal.c (sreal::dump): Rename from dump_sreal. > (debug): Adjust. > (copy): Remove function. > (sreal::shift_right): Rename from sreal_sift_right. > (sreal::normalize): Rename from normalize. > (sreal_init): Remove function. > (sreal::to_int): Rename from sreal_to_int. > (sreal_compare): Remove function. > (sreal::operator+): Rename from sreal_add. > (sreal::operator-): Rename from sreal_sub. > (sreal::operator*): Rename from sreal_mul. > (sreal::operator/): Rename from sreal_div. > * sreal.h (class sreal): Adjust. > (inline sreal &operator+=): New operator. > (inline sreal &operator-=): Likewise. > (inline sreal &operator/=): Likewise. > (inline sreal &operator*=): Likewise. > (inline bool operator!=): Likewise. > (inline bool operator>): Likewise. > (inline bool operator<=): Likewise. > (inline bool operator>=): Likewise. > --- > gcc/ipa-inline.c | 25 ++- > gcc/predict.c| 82 -- > gcc/sreal.c | 479 > +++ > gcc/sreal.h | 97 --- > 4 files changed, 213 insertions(+), 470 deletions(-) > > diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c > index e79a4dd..cca1fb3 100644 > --- a/gcc/ipa-inline.c > +++ b/gcc/ipa-inline.c > @@ -939,29 +939,28 @@ edge_badness (struct cgraph_edge *edge, bool dump) > >else if (max_count) > { > - sreal tmp, relbenefit_real, growth_real; >int relbenefit = relative_time_benefit (callee_info, edge, edge_time); >/* Capping edge->count to max_count. edge->count can be larger than > max_count if an inline adds new edges which increase max_count > after max_count is computed. */ >gcov_type edge_count = edge->count > max_count ? max_count : > edge->count; > > - sreal_init (&relbenefit_real, relbenefit, 0); > - sreal_init (&growth_real, growth, 0); > + sreal relbenefit_real (relbenefit, 0); > + sreal growth_real (growth, 0); > >/* relative_edge_count. */ > - sreal_init (&tmp, edge_count, 0); > - sreal_div (&tmp, &tmp, &max_count_real); > + sreal tmp (edge_count, 0); > + tmp /= max_count_real; > >/* relative_time_benefit. */ > - sreal_mul (&tmp, &tmp, &relbenefit_real); > - sreal_div (&tmp, &tmp, &max_relbenefit_real); > + tmp *= relbenefit_real; > + tmp /= max_relbenefit_real; > >/* growth_f_caller. */ > - sreal_mul (&tmp, &tmp, &half_int_min_real); > - sreal_div (&tmp, &tmp, &growth_real); > + tmp *= half_int_min_real; > + tmp /= growth_real; > > - badness = -1 * sreal_to_int (&tmp); > + badness = -1 * tmp.to_int (); > >if (dump) > { > @@ -1604,9 +1603,9 @@ inline_small_functions (void) > if (max_count < edge->count) > max_count = edge->count; >} > - sreal_init (&max_count_real, max_count, 0); > - sreal_init (&max_relbenefit_real, RELATIVE_TIME_BENEFIT_RANGE, 0); > - sreal_init (&half_int_min_real, INT_MAX / 2, 0); > + max_count_real = sreal (max_count, 0); > + max_relbenefit_real = sreal (RELATIVE_TIME_BENEFIT_RANGE, 0); > + half_int_min_real = sreal (INT_MAX / 2, 0); >ipa_free_postorder_info (); >initialize_growth_caches (); > > diff --git a/gcc/predict.c b/gcc/predict.c > index 5f5d4a5..10675c3 100644 > --- a/gcc/predict.c > +++ b/gcc/predict.c > @@ -2571,15 +2571,13 @@ propagate_freq (basic_block head, bitmap tovisit) > bb->count = bb->frequency = 0; > } > > - memcpy (&BLOCK_INFO (head)->frequency, &real_one, sizeof (real_one)); > + BLOCK_INFO (head)->frequency = real_one; >last = head; >for (bb = head; bb; bb = nextbb) > { >edge_iterator ei; > - sreal cyclic_probability, frequency; > - > - memcpy (&cyclic_probability, &real_zero, sizeof (real_zero)); > - memcpy (&frequency, &real_zero, sizeof (real_zero)); > + sreal cyclic_probability = real_zero; > + sreal frequency = real_zero; > >nextbb = BLOCK_INFO (bb)->next; >BLOCK_INFO (bb)->next = NULL; > @@ -2596,42 +2594,34 @@ propagate_freq (basic_block head, bitmap tovisit) > FOR_EACH_EDGE (e, ei, bb->preds) > if (EDGE_INFO (e)->back_edge) > { > - sreal_add (&cyclic_probability, &cyc
Re: [PATCH] c++ify sreal
On Fri, Oct 24, 2014 at 1:55 AM, Richard Biener wrote: > On Fri, Oct 24, 2014 at 8:28 AM, wrote: >> From: Trevor Saunders >> >> Hi, >> >> do $subject, and cleanup for always 64 bit hwi. >> >> >> bootstrapped + regtested x86_64-unknown-linux-gnu, ok? > > Ok. Can you please replace remaining HOST_WIDE_INT > vestiges in there with [u]int64_t please? This patch breaks the build on debian 6.0: ../../gcc/sreal.c: In member function ‘int64_t sreal::to_int() const’: ../../gcc/sreal.c:159: error: ‘INT64_MAX’ was not declared in this scope Thanks, Andrew Pinski > > Thanks, > Richard. > >> Trev >> >> gcc/ChangeLog: >> >> 2014-10-24 Trevor Saunders >> >> * ipa-inline.c (edge_badness): Adjust. >> (inline_small_functions): Likewise. >> * predict.c (propagate_freq): Likewise. >> (estimate_bb_frequencies): Likewise. >> * sreal.c (sreal::dump): Rename from dump_sreal. >> (debug): Adjust. >> (copy): Remove function. >> (sreal::shift_right): Rename from sreal_sift_right. >> (sreal::normalize): Rename from normalize. >> (sreal_init): Remove function. >> (sreal::to_int): Rename from sreal_to_int. >> (sreal_compare): Remove function. >> (sreal::operator+): Rename from sreal_add. >> (sreal::operator-): Rename from sreal_sub. >> (sreal::operator*): Rename from sreal_mul. >> (sreal::operator/): Rename from sreal_div. >> * sreal.h (class sreal): Adjust. >> (inline sreal &operator+=): New operator. >> (inline sreal &operator-=): Likewise. >> (inline sreal &operator/=): Likewise. >> (inline sreal &operator*=): Likewise. >> (inline bool operator!=): Likewise. >> (inline bool operator>): Likewise. >> (inline bool operator<=): Likewise. >> (inline bool operator>=): Likewise. >> --- >> gcc/ipa-inline.c | 25 ++- >> gcc/predict.c| 82 -- >> gcc/sreal.c | 479 >> +++ >> gcc/sreal.h | 97 --- >> 4 files changed, 213 insertions(+), 470 deletions(-) >> >> diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c >> index e79a4dd..cca1fb3 100644 >> --- a/gcc/ipa-inline.c >> +++ b/gcc/ipa-inline.c >> @@ -939,29 +939,28 @@ edge_badness (struct cgraph_edge *edge, bool dump) >> >>else if (max_count) >> { >> - sreal tmp, relbenefit_real, growth_real; >>int relbenefit = relative_time_benefit (callee_info, edge, edge_time); >>/* Capping edge->count to max_count. edge->count can be larger than >> max_count if an inline adds new edges which increase max_count >> after max_count is computed. */ >>gcov_type edge_count = edge->count > max_count ? max_count : >> edge->count; >> >> - sreal_init (&relbenefit_real, relbenefit, 0); >> - sreal_init (&growth_real, growth, 0); >> + sreal relbenefit_real (relbenefit, 0); >> + sreal growth_real (growth, 0); >> >>/* relative_edge_count. */ >> - sreal_init (&tmp, edge_count, 0); >> - sreal_div (&tmp, &tmp, &max_count_real); >> + sreal tmp (edge_count, 0); >> + tmp /= max_count_real; >> >>/* relative_time_benefit. */ >> - sreal_mul (&tmp, &tmp, &relbenefit_real); >> - sreal_div (&tmp, &tmp, &max_relbenefit_real); >> + tmp *= relbenefit_real; >> + tmp /= max_relbenefit_real; >> >>/* growth_f_caller. */ >> - sreal_mul (&tmp, &tmp, &half_int_min_real); >> - sreal_div (&tmp, &tmp, &growth_real); >> + tmp *= half_int_min_real; >> + tmp /= growth_real; >> >> - badness = -1 * sreal_to_int (&tmp); >> + badness = -1 * tmp.to_int (); >> >>if (dump) >> { >> @@ -1604,9 +1603,9 @@ inline_small_functions (void) >> if (max_count < edge->count) >> max_count = edge->count; >>} >> - sreal_init (&max_count_real, max_count, 0); >> - sreal_init (&max_relbenefit_real, RELATIVE_TIME_BENEFIT_RANGE, 0); >> - sreal_init (&half_int_min_real, INT_MAX / 2, 0); >> + max_count_real = sreal (max_count, 0); >> + max_relbenefit_real = sreal (RELATIVE_TIME_BENEFIT_RANGE, 0); >> + half_int_min_real = sreal (INT_MAX / 2, 0); >>ipa_free_postorder_info (); >>initialize_growth_caches (); >> >> diff --git a/gcc/predict.c b/gcc/predict.c >> index 5f5d4a5..10675c3 100644 >> --- a/gcc/predict.c >> +++ b/gcc/predict.c >> @@ -2571,15 +2571,13 @@ propagate_freq (basic_block head, bitmap tovisit) >> bb->count = bb->frequency = 0; >> } >> >> - memcpy (&BLOCK_INFO (head)->frequency, &real_one, sizeof (real_one)); >> + BLOCK_INFO (head)->frequency = real_one; >>last = head; >>for (bb = head; bb; bb = nextbb) >> { >>edge_iterator ei; >> - sreal cyclic_probability, frequency; >> - >> - memcpy (&cyclic_probability, &real_zero, sizeof (real_zero)); >> - memcpy (&frequency, &real_zero, sizeof (real_zero))
Re: [PATCH] c++ify sreal
Hello! >>> do $subject, and cleanup for always 64 bit hwi. >>> >>> >>> bootstrapped + regtested x86_64-unknown-linux-gnu, ok? >> >> Ok. Can you please replace remaining HOST_WIDE_INT >> vestiges in there with [u]int64_t please? > > > This patch breaks the build on debian 6.0: > > ../../gcc/sreal.c: In member function âint64_t sreal::to_int() constâ: > ../../gcc/sreal.c:159: error: âINT64_MAXâ was not declared in this scope Index: system.h === --- system.h(revision 217338) +++ system.h(working copy) @@ -27,6 +27,7 @@ event inttypes.h gets pulled in by another header it is already defined. */ #define __STDC_FORMAT_MACROS +#define __STDC_LIMIT_MACROS /* We must include stdarg.h before stdio.h. */ #include
Re: [PATCH] c++ify sreal
On Tue, Nov 11, 2014 at 08:51:41AM +0100, Uros Bizjak wrote: > Hello! > > >>> do $subject, and cleanup for always 64 bit hwi. > >>> > >>> > >>> bootstrapped + regtested x86_64-unknown-linux-gnu, ok? > >> > >> Ok. Can you please replace remaining HOST_WIDE_INT > >> vestiges in there with [u]int64_t please? > > > > > > This patch breaks the build on debian 6.0: > > > > ../../gcc/sreal.c: In member function âint64_t sreal::to_int() constâ: > > ../../gcc/sreal.c:159: error: âINT64_MAXâ was not declared in this scope > > Index: system.h > === > --- system.h(revision 217338) > +++ system.h(working copy) > @@ -27,6 +27,7 @@ > event inttypes.h gets pulled in by another header it is already > defined. */ > #define __STDC_FORMAT_MACROS > +#define __STDC_LIMIT_MACROS > > /* We must include stdarg.h before stdio.h. */ > #include Still, I don't believe it will be portable everywhere. Can't you use INTTYPE_MAXIMUM (int64_t) instead of INT64_MAX? We already use that in GCC... Jakub
Re: [PATCH] c++ify sreal
On Tue, Nov 11, 2014 at 9:11 AM, Jakub Jelinek wrote: >> >>> do $subject, and cleanup for always 64 bit hwi. >> >>> >> >>> >> >>> bootstrapped + regtested x86_64-unknown-linux-gnu, ok? >> >> >> >> Ok. Can you please replace remaining HOST_WIDE_INT >> >> vestiges in there with [u]int64_t please? >> > >> > >> > This patch breaks the build on debian 6.0: >> > >> > ../../gcc/sreal.c: In member function āint64_t sreal::to_int() constā: >> > ../../gcc/sreal.c:159: error: āINT64_MAXā was not declared in this scope >> > Still, I don't believe it will be portable everywhere. > Can't you use > INTTYPE_MAXIMUM (int64_t) instead of INT64_MAX? We already use that > in GCC... Yes, following patch also bootstraps: --cut here-- Index: sreal.c === --- sreal.c (revision 217338) +++ sreal.c (working copy) @@ -156,7 +156,7 @@ sreal::to_int () const if (m_exp <= -SREAL_BITS) return 0; if (m_exp >= SREAL_PART_BITS) -return INT64_MAX; +return INTTYPE_MAXIMUM (int64_t); if (m_exp > 0) return m_sig << m_exp; if (m_exp < 0) --cut here-- Uros.
Re: [PATCH] c++ify sreal
On Tue, Nov 11, 2014 at 09:45:38AM +0100, Uros Bizjak wrote: > On Tue, Nov 11, 2014 at 9:11 AM, Jakub Jelinek wrote: > > >> >>> do $subject, and cleanup for always 64 bit hwi. > >> >>> > >> >>> > >> >>> bootstrapped + regtested x86_64-unknown-linux-gnu, ok? > >> >> > >> >> Ok. Can you please replace remaining HOST_WIDE_INT > >> >> vestiges in there with [u]int64_t please? > >> > > >> > > >> > This patch breaks the build on debian 6.0: > >> > > >> > ../../gcc/sreal.c: In member function āint64_t sreal::to_int() constā: > >> > ../../gcc/sreal.c:159: error: āINT64_MAXā was not declared in this scope > >> > > > Still, I don't believe it will be portable everywhere. > > Can't you use > > INTTYPE_MAXIMUM (int64_t) instead of INT64_MAX? We already use that > > in GCC... > > Yes, following patch also bootstraps: This is ok for trunk with appropriate ChangeLog entry. Thanks. > --- sreal.c (revision 217338) > +++ sreal.c (working copy) > @@ -156,7 +156,7 @@ sreal::to_int () const >if (m_exp <= -SREAL_BITS) > return 0; >if (m_exp >= SREAL_PART_BITS) > -return INT64_MAX; > +return INTTYPE_MAXIMUM (int64_t); >if (m_exp > 0) > return m_sig << m_exp; >if (m_exp < 0) > --cut here-- Jakub
Re: [PATCH] c++ify sreal
On Tue, 11 Nov 2014, Jakub Jelinek wrote: On Tue, Nov 11, 2014 at 08:51:41AM +0100, Uros Bizjak wrote: Hello! do $subject, and cleanup for always 64 bit hwi. bootstrapped + regtested x86_64-unknown-linux-gnu, ok? Ok. Can you please replace remaining HOST_WIDE_INT vestiges in there with [u]int64_t please? This patch breaks the build on debian 6.0: ../../gcc/sreal.c: In member function âint64_t sreal::to_int() constâ: ../../gcc/sreal.c:159: error: âINT64_MAXâ was not declared in this scope Index: system.h === --- system.h(revision 217338) +++ system.h(working copy) @@ -27,6 +27,7 @@ event inttypes.h gets pulled in by another header it is already defined. */ #define __STDC_FORMAT_MACROS +#define __STDC_LIMIT_MACROS /* We must include stdarg.h before stdio.h. */ #include Still, I don't believe it will be portable everywhere. Can't you use INTTYPE_MAXIMUM (int64_t) instead of INT64_MAX? We already use that in GCC... We could also start using the standard C++ mechanism (numeric_limits). (nothing wrong with INTTYPE_MAXIMUM, just an alternative) -- Marc Glisse
Re: [PATCH] c++ify sreal
On Tue, Nov 11, 2014 at 1:23 AM, Marc Glisse wrote: > On Tue, 11 Nov 2014, Jakub Jelinek wrote: > >> On Tue, Nov 11, 2014 at 08:51:41AM +0100, Uros Bizjak wrote: >>> >>> Hello! >>> >> do $subject, and cleanup for always 64 bit hwi. >> >> >> bootstrapped + regtested x86_64-unknown-linux-gnu, ok? > > > Ok. Can you please replace remaining HOST_WIDE_INT > vestiges in there with [u]int64_t please? This patch breaks the build on debian 6.0: ../../gcc/sreal.c: In member function āint64_t sreal::to_int() constā: ../../gcc/sreal.c:159: error: āINT64_MAXā was not declared in this scope >>> >>> >>> Index: system.h >>> === >>> --- system.h(revision 217338) >>> +++ system.h(working copy) >>> @@ -27,6 +27,7 @@ >>> event inttypes.h gets pulled in by another header it is already >>> defined. */ >>> #define __STDC_FORMAT_MACROS >>> +#define __STDC_LIMIT_MACROS >>> >>> /* We must include stdarg.h before stdio.h. */ >>> #include >> >> >> Still, I don't believe it will be portable everywhere. >> Can't you use >> INTTYPE_MAXIMUM (int64_t) instead of INT64_MAX? We already use that >> in GCC... > > > We could also start using the standard C++ mechanism (numeric_limits). Except int64_t does not have to be defined for a C++ implementation. Thanks, Andrew > > (nothing wrong with INTTYPE_MAXIMUM, just an alternative) > > -- > Marc Glisse
Re: [PATCH] c++ify sreal
On Tue, Nov 11, 2014 at 1:08 PM, Andrew Pinski wrote: > On Tue, Nov 11, 2014 at 1:23 AM, Marc Glisse wrote: >> On Tue, 11 Nov 2014, Jakub Jelinek wrote: >> >>> On Tue, Nov 11, 2014 at 08:51:41AM +0100, Uros Bizjak wrote: Hello! >>> do $subject, and cleanup for always 64 bit hwi. >>> >>> >>> bootstrapped + regtested x86_64-unknown-linux-gnu, ok? >> >> >> Ok. Can you please replace remaining HOST_WIDE_INT >> vestiges in there with [u]int64_t please? > > > > This patch breaks the build on debian 6.0: > > ../../gcc/sreal.c: In member function āint64_t sreal::to_int() constā: > ../../gcc/sreal.c:159: error: āINT64_MAXā was not declared in this scope Index: system.h === --- system.h(revision 217338) +++ system.h(working copy) @@ -27,6 +27,7 @@ event inttypes.h gets pulled in by another header it is already defined. */ #define __STDC_FORMAT_MACROS +#define __STDC_LIMIT_MACROS /* We must include stdarg.h before stdio.h. */ #include >>> >>> >>> Still, I don't believe it will be portable everywhere. >>> Can't you use >>> INTTYPE_MAXIMUM (int64_t) instead of INT64_MAX? We already use that >>> in GCC... >> >> >> We could also start using the standard C++ mechanism (numeric_limits). > > Except int64_t does not have to be defined for a C++ implementation. Also not through stdint.h / cstdint? Note that we should only care for what happens in practice here. I hope that at least for more recent standards than C++04 (which is what we require IIRC) they are on parity with C99. Richard. > Thanks, > Andrew > >> >> (nothing wrong with INTTYPE_MAXIMUM, just an alternative) >> >> -- >> Marc Glisse
Re: [PATCH] c++ify sreal
On Tue, Nov 11, 2014 at 4:54 AM, Richard Biener wrote: > On Tue, Nov 11, 2014 at 1:08 PM, Andrew Pinski wrote: >> On Tue, Nov 11, 2014 at 1:23 AM, Marc Glisse wrote: >>> On Tue, 11 Nov 2014, Jakub Jelinek wrote: >>> On Tue, Nov 11, 2014 at 08:51:41AM +0100, Uros Bizjak wrote: > > Hello! > do $subject, and cleanup for always 64 bit hwi. bootstrapped + regtested x86_64-unknown-linux-gnu, ok? >>> >>> >>> Ok. Can you please replace remaining HOST_WIDE_INT >>> vestiges in there with [u]int64_t please? >> >> >> >> This patch breaks the build on debian 6.0: >> >> ../../gcc/sreal.c: In member function āint64_t sreal::to_int() constā: >> ../../gcc/sreal.c:159: error: āINT64_MAXā was not declared in this scope > > > Index: system.h > === > --- system.h(revision 217338) > +++ system.h(working copy) > @@ -27,6 +27,7 @@ > event inttypes.h gets pulled in by another header it is already > defined. */ > #define __STDC_FORMAT_MACROS > +#define __STDC_LIMIT_MACROS > > /* We must include stdarg.h before stdio.h. */ > #include Still, I don't believe it will be portable everywhere. Can't you use INTTYPE_MAXIMUM (int64_t) instead of INT64_MAX? We already use that in GCC... >>> >>> >>> We could also start using the standard C++ mechanism (numeric_limits). >> >> Except int64_t does not have to be defined for a C++ implementation. > > Also not through stdint.h / cstdint? Note that we should only care > for what happens in practice here. I hope that at least for more recent > standards than C++04 (which is what we require IIRC) they are on > parity with C99. C++03 did not add long long, only C++11 did. Thanks, Andrew Pinski > > Richard. > >> Thanks, >> Andrew >> >>> >>> (nothing wrong with INTTYPE_MAXIMUM, just an alternative) >>> >>> -- >>> Marc Glisse