From 350b17ef4ffedff588e2c5ff04c4220ef2729bc8 Mon Sep 17 00:00:00 2001
From: hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Thu, 28 Mar 2002 12:25:21 +0000
Subject: [PATCH] 	* rtlanal.c: Include flags.h 	(may_trap_p): Do not
 mark FP operations if trapping 	if !flag_trapping_math 	* Makefile.in
 (rtlanal.o): Add dependency on flag.h 	* ifcvt.c (noce_operand_ok): Avoid the
 lameness.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@51508 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog      |  8 ++++++++
 gcc/Makefile.in    |  2 +-
 gcc/cfgcleanup.c   | 11 ++++++++---
 gcc/ifcvt.c        | 29 -----------------------------
 gcc/java/ChangeLog |  4 ++++
 gcc/java/lang.c    |  3 +++
 gcc/rtlanal.c      |  9 +++++++--
 7 files changed, 31 insertions(+), 35 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 338c6b14073c..e1dcc5d3cddc 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+Thu Mar 28 13:21:53 CET 2002  Jan Hubicka  <jh@suse.cz>
+
+	* rtlanal.c: Include flags.h
+	(may_trap_p): Do not mark FP operations if trapping
+	if !flag_trapping_math
+	* Makefile.in (rtlanal.o): Add dependency on flag.h
+	* ifcvt.c (noce_operand_ok): Avoid the lameness.
+
 2002-03-27  Zack Weinberg  <zack@codesourcery.com>
 
 	* mips.md: Use dconst1, not 1.0, as first argument of
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 2a71b731bf14..c5192e964225 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -1366,7 +1366,7 @@ print-rtl.o : print-rtl.c $(GCONFIG_H) $(SYSTEM_H) $(RTL_H) $(TREE_H) \
 	$(CC) -c $(ALL_CFLAGS) -DGENERATOR_FILE $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)
 
 rtlanal.o : rtlanal.c $(CONFIG_H) $(SYSTEM_H) toplev.h $(RTL_H) \
-   hard-reg-set.h $(TM_P_H) insn-config.h $(RECOG_H)
+   hard-reg-set.h $(TM_P_H) insn-config.h $(RECOG_H) flags.h
 
 errors.o : errors.c $(GCONFIG_H) $(SYSTEM_H) errors.h
 	$(CC) -c $(ALL_CFLAGS) -DGENERATOR_FILE $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)
diff --git a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c
index a1d5c64d52b5..f31f168f7b51 100644
--- a/gcc/cfgcleanup.c
+++ b/gcc/cfgcleanup.c
@@ -1467,6 +1467,7 @@ try_crossjump_bb (mode, bb)
 {
   edge e, e2, nexte2, nexte, fallthru;
   bool changed;
+  int n = 0;
 
   /* Nothing to do if there is not at least two incoming edges.  */
   if (!bb->pred || !bb->pred->pred_next)
@@ -1475,9 +1476,13 @@ try_crossjump_bb (mode, bb)
   /* It is always cheapest to redirect a block that ends in a branch to
      a block that falls through into BB, as that adds no branches to the
      program.  We'll try that combination first.  */
-  for (fallthru = bb->pred; fallthru; fallthru = fallthru->pred_next)
-    if (fallthru->flags & EDGE_FALLTHRU)
-      break;
+  for (fallthru = bb->pred; fallthru; fallthru = fallthru->pred_next, n++)
+    {
+      if (fallthru->flags & EDGE_FALLTHRU)
+	break;
+      if (n > 100)
+	return false;
+    }
 
   changed = false;
   for (e = bb->pred; e; e = nexte)
diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c
index 989fa5cdd44e..f912654da219 100644
--- a/gcc/ifcvt.c
+++ b/gcc/ifcvt.c
@@ -1554,35 +1554,6 @@ noce_operand_ok (op)
   if (side_effects_p (op))
     return FALSE;
 
-  /* ??? Unfortuantely may_trap_p can't look at flag_trapping_math, due to
-     being linked into the genfoo programs.  This is probably a mistake.
-     With finite operands, most fp operations don't trap.  */
-  if (!flag_trapping_math && FLOAT_MODE_P (GET_MODE (op)))
-    switch (GET_CODE (op))
-      {
-      case DIV:
-      case MOD:
-      case UDIV:
-      case UMOD:
-	/* ??? This is kinda lame -- almost every target will have forced
-	   the constant into a register first.  But given the expense of
-	   division, this is probably for the best.  */
-	return (CONSTANT_P (XEXP (op, 1))
-		&& XEXP (op, 1) != CONST0_RTX (GET_MODE (op))
-		&& ! may_trap_p (XEXP (op, 0)));
-
-      default:
-	switch (GET_RTX_CLASS (GET_CODE (op)))
-	  {
-	  case '1':
-	    return ! may_trap_p (XEXP (op, 0));
-	  case 'c':
-	  case '2':
-	    return ! may_trap_p (XEXP (op, 0)) && ! may_trap_p (XEXP (op, 1));
-	  }
-	break;
-      }
-
   return ! may_trap_p (op);
 }
 
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog
index b284d0c8a5e5..c1d3908a7119 100644
--- a/gcc/java/ChangeLog
+++ b/gcc/java/ChangeLog
@@ -1,3 +1,7 @@
+Thu Mar 28 13:22:22 CET 2002  Jan Hubicka  <jh@suse.cz>
+
+	* java/lang.c (java_init_options): Set flag_trapping_math to 0.
+
 2002-03-28  Bryce McKinlay  <bryce@waitaki.otago.ac.nz>
 
 	* parse.y (resolve_package): Initialize "decl".
diff --git a/gcc/java/lang.c b/gcc/java/lang.c
index 56f16195a0db..fd197235cd42 100644
--- a/gcc/java/lang.c
+++ b/gcc/java/lang.c
@@ -752,4 +752,7 @@ java_init_options ()
   flag_bounds_check = 1;
   flag_exceptions = 1;
   flag_non_call_exceptions = 1;
+
+  /* In Java floating point operations never trap.  */
+  flag_trapping_math = 0;
 }
diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c
index 79ccf9d4bc08..9348fd01d118 100644
--- a/gcc/rtlanal.c
+++ b/gcc/rtlanal.c
@@ -28,6 +28,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "insn-config.h"
 #include "recog.h"
 #include "tm_p.h"
+#include "flags.h"
 
 /* Forward declarations */
 static int global_reg_mentioned_p_1 PARAMS ((rtx *, void *));
@@ -2348,7 +2349,8 @@ may_trap_p (x)
     case UDIV:
     case UMOD:
       if (! CONSTANT_P (XEXP (x, 1))
-	  || GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT)
+	  || (GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT
+	      && flag_trapping_math))
 	return 1;
       /* This was const0_rtx, but by not using that,
 	 we can link this file into other programs.  */
@@ -2367,6 +2369,8 @@ may_trap_p (x)
     case LT:
     case COMPARE:
       /* Some floating point comparisons may trap.  */
+      if (!flag_trapping_math)
+	break;
       /* ??? There is no machine independent way to check for tests that trap
 	 when COMPARE is used, though many targets do make this distinction.
 	 For instance, sparc uses CCFPE for compares which generate exceptions
@@ -2387,7 +2391,8 @@ may_trap_p (x)
 
     default:
       /* Any floating arithmetic may trap.  */
-      if (GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT)
+      if (GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT
+	  && flag_trapping_math)
 	return 1;
     }
 
-- 
GitLab