public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Avoid division by zero in fold_loop_internal_call
@ 2023-08-14 15:59 Jan Hubicka
  0 siblings, 0 replies; only message in thread
From: Jan Hubicka @ 2023-08-14 15:59 UTC (permalink / raw)
  To: gcc-patches

Hi,
My patch to fix profile after folding internal call is missing check for the
case profile was already zero before if-conversion.

Bootstrapped/regtested x86_64-linux, comitted.

gcc/ChangeLog:

	PR gcov-profile/110988
	* tree-cfg.cc (fold_loop_internal_call): Avoid division by zero.

diff --git a/gcc/tree-cfg.cc b/gcc/tree-cfg.cc
index ab1f8067c54..105f4b1c953 100644
--- a/gcc/tree-cfg.cc
+++ b/gcc/tree-cfg.cc
@@ -7734,11 +7734,14 @@ fold_loop_internal_call (gimple *g, tree value)
 		 test.  This should not happen as the guarded code should
 		 start with pre-header.  */
 	      gcc_assert (single_pred_edge (taken_edge->dest));
-	      taken_edge->dest->count
-		= taken_edge->dest->count.apply_scale (new_count,
-						       old_count);
-	      scale_strictly_dominated_blocks (taken_edge->dest,
-					       new_count, old_count);
+	      if (old_count.nonzero_p ())
+		{
+		  taken_edge->dest->count
+		    = taken_edge->dest->count.apply_scale (new_count,
+							   old_count);
+		  scale_strictly_dominated_blocks (taken_edge->dest,
+						   new_count, old_count);
+		}
 	    }
 	}
     }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-08-14 15:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-14 15:59 Avoid division by zero in fold_loop_internal_call Jan Hubicka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).