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]

PATCH: Use flag_trapping_math


The following simple patch uses flag_trapping_math to make the
decision about whether an instruction can trap more precise.
It also fixes a comment.

The patch is agains yesterday's trunk; it bootstraps on
sparc-sun-solaris2.8 with BOOT_CFLAGS='-O2 -g -fno-trapping-math'
without any new warnings, and shows no regressions on make -k check.

I don't have check-in privileges, so if you like it, check it in.

Brad

	* rtlanal.c: Include flags.h.
	(rtx_addr_can_trap_p): Fix introductory comment.
	(may_trap_p): If flag_trapping_math is 0, then assume that
	floating-point math operations cannot trap.

===================================================================
RCS file: RCS/rtlanal.c,v
retrieving revision 1.1
diff -p -r1.1 rtlanal.c
*** rtlanal.c	2001/03/17 03:12:38	1.1
--- rtlanal.c	2001/03/17 03:45:16
*************** Boston, MA 02111-1307, USA.  */
*** 25,30 ****
--- 25,31 ----
  #include "toplev.h"
  #include "rtl.h"
  #include "hard-reg-set.h"
+ #include "flags.h"
  
  /* Forward declarations */
  static void set_of_1		PARAMS ((rtx, rtx, void *));
*************** rtx_varies_p (x, for_alias)
*** 196,202 ****
    return 0;
  }
  
! /* Return 0 if the use of X as an address in a MEM can cause a trap.  */
  
  int
  rtx_addr_can_trap_p (x)
--- 197,203 ----
    return 0;
  }
  
! /* Return nonzero if the use of X as an address in a MEM can cause a trap.  */
  
  int
  rtx_addr_can_trap_p (x)
*************** may_trap_p (x)
*** 1984,1996 ****
      case MEM:
        return rtx_addr_can_trap_p (XEXP (x, 0));
  
-       /* Division by a non-constant might trap.  */
      case DIV:
      case MOD:
      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.  */
--- 1985,2005 ----
      case MEM:
        return rtx_addr_can_trap_p (XEXP (x, 0));
  
      case DIV:
      case MOD:
      case UDIV:
      case UMOD:
!       /* The flag flag_trapping_math determines whether floating-point
! 	 divides can trap.  */
!       if (GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT)
! 	{
! 	  if (flag_trapping_math)
! 	    return 1;
! 	  else
! 	    break;
! 	}
!       /* Division by a non-constant might trap.  */
!       if (! CONSTANT_P (XEXP (x, 1)))
  	return 1;
        /* This was const0_rtx, but by not using that,
  	 we can link this file into other programs.  */
*************** may_trap_p (x)
*** 2013,2024 ****
  	 when COMPARE is used, though many targets do make this distinction.
  	 For instance, sparc uses CCFPE for compares which generate exceptions
  	 and CCFP for compares which do not generate exceptions.  */
!       if (GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT)
  	return 1;
        /* But often the compare has some CC mode, so check operand
  	 modes as well.  */
!       if (GET_MODE_CLASS (GET_MODE (XEXP (x, 0))) == MODE_FLOAT
! 	  || GET_MODE_CLASS (GET_MODE (XEXP (x, 1))) == MODE_FLOAT)
  	return 1;
        break;
  
--- 2022,2034 ----
  	 when COMPARE is used, though many targets do make this distinction.
  	 For instance, sparc uses CCFPE for compares which generate exceptions
  	 and CCFP for compares which do not generate exceptions.  */
!       if (GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT && flag_trapping_math)
  	return 1;
        /* But often the compare has some CC mode, so check operand
  	 modes as well.  */
!       if ((GET_MODE_CLASS (GET_MODE (XEXP (x, 0))) == MODE_FLOAT
! 	   || GET_MODE_CLASS (GET_MODE (XEXP (x, 1))) == MODE_FLOAT)
! 	  && flag_trapping_math)
  	return 1;
        break;
  
*************** may_trap_p (x)
*** 2029,2035 ****
  
      default:
        /* Any floating arithmetic may trap.  */
!       if (GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT)
  	return 1;
      }
  
--- 2039,2045 ----
  
      default:
        /* Any floating arithmetic may trap.  */
!       if (GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT && flag_trapping_math)
  	return 1;
      }
  


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