This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] PR40119


Hi,

This fixes PR40119, which concerns a floating-point error
(divide-by-zero) when "--param hot-bb-frequency-fraction=0" is given.

Solution is simple: Catch this exceptional case early.

Bootstrapped&tested on x86_64-unknown-linux-gnu (C only). OK for trunk?

Ciao!
Steven


gcc/
	* predict.c (maybe_hot_frequency_p): If a frequency of 0 is also
	to be considered "hot", return true at once.
	(cgraph_maybe_hot_edge_p): Likewise.

testsuite/
	gcc.dg/pr40119.c: New test.

Index: predict.c
===================================================================
--- predict.c	(revision 156706)
+++ predict.c	(working copy)
@@ -113,6 +113,8 @@ static const struct predictor_info predi
 static inline bool
 maybe_hot_frequency_p (int freq)
 {
+  if (PARAM_VALUE (HOT_BB_FREQUENCY_FRACTION) == 0)
+    return true;
   if (!profile_info || !flag_branch_probabilities)
     {
       if (cfun->function_frequency == FUNCTION_FREQUENCY_UNLIKELY_EXECUTED)
@@ -157,6 +159,8 @@ maybe_hot_bb_p (const_basic_block bb)
 bool
 cgraph_maybe_hot_edge_p (struct cgraph_edge *edge)
 {
+  if (PARAM_VALUE (HOT_BB_FREQUENCY_FRACTION) == 0)
+    return true;
   if (profile_info && flag_branch_probabilities
       && (edge->count
 	  <= profile_info->sum_max / PARAM_VALUE (HOT_BB_COUNT_FRACTION)))
Index: testsuite/gcc.dg/pr40119.c
===================================================================
--- testsuite/gcc.dg/pr40119.c	(revision 0)
+++ testsuite/gcc.dg/pr40119.c	(revision 0)
@@ -0,0 +1,5 @@
+/* PR middle-end/40119 */
+/* { dg-do compile } */
+/* { dg-options "-O --param hot-bb-frequency-fraction=0" } */
+void foo(void) { return; }
+


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]