This is the mail archive of the java@gcc.gnu.org mailing list for the Java 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]

nontrapping math in Java


> On Wed, Mar 13, 2002 at 10:27:09PM +0100, Jan Hubicka wrote:
> > Nice, I guess I should submit patch to may_trap_p to actually
> > use this flag as well :)
> 
> Note comment in ifcvt.c.  It's possibly not true anymore, but...

Seem to be the case.  I've bootstrapped/regtested i386 the attached patch.
OK for mainline and branch?

Another case are the Java references.  If I understand it well (the pointers
can be eighter NULL or valid) we are too conservative.  We may safely
omit the eh edges on all references mentioning stack pointer, symbols and
friends as we know they are not using pointers, just indexes.
Perhaps the presence of pointers can be even made explicit in the MEM
tracking.  This way we may omit huge amount of EH edges and majority of
rest via delete_null_pointer_checks.  That can be considerable performance
hit for Java I guess.

We need to invent flag for this. What about -fvalid_or_null_references?

Did someone run benchmark with and without -fnon-call-exceptions?

Honza

Sun Mar 24 18:45:34 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
	* java/lang.c (java_init_options): Set flag_trapping_math to 0.
	* Makefile.in (rtlanal.o): Add dependency on flag.h
	* ifcvt.c (noce_operand_ok): Avoid the lameness.

Index: rtlanal.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/rtlanal.c,v
retrieving revision 1.115.2.9
diff -c -3 -p -r1.115.2.9 rtlanal.c
*** rtlanal.c	2002/03/24 15:00:06	1.115.2.9
--- rtlanal.c	2002/03/24 17:43:30
*************** Software Foundation, 59 Temple Place - S
*** 28,33 ****
--- 28,34 ----
  #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 *));
*************** may_trap_p (x)
*** 2348,2354 ****
      case UDIV:
      case UMOD:
        if (! CONSTANT_P (XEXP (x, 1))
! 	  || GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT)
  	return 1;
        /* This was const0_rtx, but by not using that,
  	 we can link this file into other programs.  */
--- 2349,2356 ----
      case UDIV:
      case UMOD:
        if (! CONSTANT_P (XEXP (x, 1))
! 	  || (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.  */
*************** may_trap_p (x)
*** 2367,2372 ****
--- 2369,2376 ----
      case LT:
      case COMPARE:
        /* Some floating point comparisons may trap.  */
+       if (!flag_trapping_math)
+ 	return 0;
        /* ??? 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
*************** may_trap_p (x)
*** 2387,2393 ****
  
      default:
        /* Any floating arithmetic may trap.  */
!       if (GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT)
  	return 1;
      }
  
--- 2391,2398 ----
  
      default:
        /* Any floating arithmetic may trap.  */
!       if (GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT
! 	  && flag_trapping_math)
  	return 1;
      }
  
Index: java/lang.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/lang.c,v
retrieving revision 1.84.2.4
diff -c -3 -p -r1.84.2.4 lang.c
*** lang.c	2002/03/24 15:02:27	1.84.2.4
--- lang.c	2002/03/24 17:43:32
*************** java_init_options ()
*** 749,752 ****
--- 749,755 ----
    flag_bounds_check = 1;
    flag_exceptions = 1;
    flag_non_call_exceptions = 1;
+ 
+   /* In Java floating point operations never trap.  */
+   flag_trapping_math = 0;
  }
Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/egcs/gcc/Makefile.in,v
retrieving revision 1.775.2.31
diff -c -3 -p -r1.775.2.31 Makefile.in
*** Makefile.in	2002/03/24 14:59:24	1.775.2.31
--- Makefile.in	2002/03/24 17:45:30
*************** print-rtl.o : print-rtl.c $(GCONFIG_H) $
*** 1367,1373 ****
  	$(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)
  
  errors.o : errors.c $(GCONFIG_H) $(SYSTEM_H) errors.h
  	$(CC) -c $(ALL_CFLAGS) -DGENERATOR_FILE $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)
--- 1367,1373 ----
  	$(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) flags.h
  
  errors.o : errors.c $(GCONFIG_H) $(SYSTEM_H) errors.h
  	$(CC) -c $(ALL_CFLAGS) -DGENERATOR_FILE $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)
Index: ifcvt.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/ifcvt.c,v
retrieving revision 1.73.2.11
diff -c -3 -p -r1.73.2.11 ifcvt.c
*** ifcvt.c	2002/03/24 14:59:52	1.73.2.11
--- ifcvt.c	2002/03/24 17:50:39
*************** noce_operand_ok (op)
*** 1597,1631 ****
    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);
  }
  
--- 1597,1602 ----


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