[PATCH] Replace #ifdef HAVE_cc0 with CC0_P

Roger Sayle roger@www.eyesopen.com
Sun Feb 2 20:50:00 GMT 2003


Kazu Hirata wrote:
> The only users of CC0_P are combine.c and gcse.c.

Not for long :>  I've been sitting on the following patch to clean-up
some of the conditional compilation in GCC, using the new CC0_P macro.
This has been tested with bootstrap and no regressions on x86, but
I've been waiting until I can test it on a cc0 target before I was
going to post it.  Unfortunately, v850 doesn't build, and my patches
to get it going are hung up, waiting for me to debug the scheduler :<

To summarise, there'll be more uses of CC0_P in the near future.


2003-02-02  Roger Sayle  <roger@eyesopen.com>

	* combine.c (combine_simplify_rtx, simplfy_comparison):  Use CC0_P.
	* cse.c (invalidate_skipped_set):  Likewise.
	* integrate.c (subst_constants):  Likewise.
	* jump.c (reversed_comparison_code_parts):  Likewise.
	* loop.c (canonicalize_condition):  Likewise.
	* simplify-rtx.c (simplify_relational_operation):  Likewise.

Index: combine.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/combine.c,v
retrieving revision 1.327
diff -c -3 -p -r1.327 combine.c
*** combine.c	10 Jan 2003 23:36:17 -0000	1.327
--- combine.c	19 Jan 2003 15:25:56 -0000
***************
*** 1,6 ****
  /* Optimize by combining instructions for GNU compiler.
     Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
!    1999, 2000, 2001, 2002 Free Software Foundation, Inc.

  This file is part of GCC.

--- 1,6 ----
  /* Optimize by combining instructions for GNU compiler.
     Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
!    1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.

  This file is part of GCC.

*************** combine_simplify_rtx (x, op0_mode, last,
*** 4425,4434 ****
  	 with it.  */
        if (GET_CODE (XEXP (x, 0)) == COMPARE
  	  || (GET_MODE_CLASS (GET_MODE (XEXP (x, 0))) != MODE_CC
! #ifdef HAVE_cc0
! 	      && XEXP (x, 0) != cc0_rtx
! #endif
! 	      ))
  	{
  	  rtx op0 = XEXP (x, 0);
  	  rtx op1 = XEXP (x, 1);
--- 4425,4431 ----
  	 with it.  */
        if (GET_CODE (XEXP (x, 0)) == COMPARE
  	  || (GET_MODE_CLASS (GET_MODE (XEXP (x, 0))) != MODE_CC
! 	      && ! CC0_P (XEXP (x, 0))))
  	{
  	  rtx op0 = XEXP (x, 0);
  	  rtx op1 = XEXP (x, 1);
*************** simplify_comparison (code, pop0, pop1)
*** 10783,10791 ****
  	  /* We can't do anything if OP0 is a condition code value, rather
  	     than an actual data value.  */
  	  if (const_op != 0
! #ifdef HAVE_cc0
! 	      || XEXP (op0, 0) == cc0_rtx
! #endif
  	      || GET_MODE_CLASS (GET_MODE (XEXP (op0, 0))) == MODE_CC)
  	    break;

--- 10780,10786 ----
  	  /* We can't do anything if OP0 is a condition code value, rather
  	     than an actual data value.  */
  	  if (const_op != 0
! 	      || CC0_P (XEXP (op0, 0))
  	      || GET_MODE_CLASS (GET_MODE (XEXP (op0, 0))) == MODE_CC)
  	    break;

Index: cse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cse.c,v
retrieving revision 1.245
diff -c -3 -p -r1.245 cse.c
*** cse.c	16 Dec 2002 18:19:19 -0000	1.245
--- cse.c	19 Jan 2003 15:26:01 -0000
***************
*** 1,6 ****
  /* Common subexpression elimination for GNU compiler.
     Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998
!    1999, 2000, 2001, 2002 Free Software Foundation, Inc.

  This file is part of GCC.

--- 1,6 ----
  /* Common subexpression elimination for GNU compiler.
     Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998
!    1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.

  This file is part of GCC.

*************** invalidate_skipped_set (dest, set, data)
*** 6670,6678 ****
      }

    if (GET_CODE (set) == CLOBBER
! #ifdef HAVE_cc0
!       || dest == cc0_rtx
! #endif
        || dest == pc_rtx)
      return;

--- 6670,6676 ----
      }

    if (GET_CODE (set) == CLOBBER
!       || CC0_P (dest)
        || dest == pc_rtx)
      return;

Index: integrate.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/integrate.c,v
retrieving revision 1.210
diff -c -3 -p -r1.210 integrate.c
*** integrate.c	3 Jan 2003 20:04:34 -0000	1.210
--- integrate.c	19 Jan 2003 15:26:01 -0000
***************
*** 1,6 ****
  /* Procedure integration for GCC.
!    Copyright (C) 1988, 1991, 1993, 1994, 1995, 1996, 1997, 1998,
!    1999, 2000, 2001, 2002 Free Software Foundation, Inc.
     Contributed by Michael Tiemann (tiemann@cygnus.com)

  This file is part of GCC.
--- 1,6 ----
  /* Procedure integration for GCC.
!    Copyright (C) 1988, 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
!    2000, 2001, 2002, 2003 Free Software Foundation, Inc.
     Contributed by Michael Tiemann (tiemann@cygnus.com)

  This file is part of GCC.
*************** subst_constants (loc, insn, map, memonly
*** 2614,2623 ****
  	  {
  	    src = SET_SRC (x);
  	    if (GET_MODE_CLASS (GET_MODE (src)) == MODE_CC
! #ifdef HAVE_cc0
! 		|| dest == cc0_rtx
! #endif
! 		)
  	      {
  		compare_mode = GET_MODE (XEXP (src, 0));
  		if (compare_mode == VOIDmode)
--- 2614,2620 ----
  	  {
  	    src = SET_SRC (x);
  	    if (GET_MODE_CLASS (GET_MODE (src)) == MODE_CC
! 		|| CC0_P (dest))
  	      {
  		compare_mode = GET_MODE (XEXP (src, 0));
  		if (compare_mode == VOIDmode)
*************** subst_constants (loc, insn, map, memonly
*** 2669,2677 ****
  			|| REGNO (XEXP (src, 0)) == VIRTUAL_STACK_VARS_REGNUM)
  		    && CONSTANT_P (XEXP (src, 1)))
  		|| GET_CODE (src) == COMPARE
! #ifdef HAVE_cc0
! 		|| dest == cc0_rtx
! #endif
  		|| (dest == pc_rtx
  		    && (src == pc_rtx || GET_CODE (src) == RETURN
  			|| GET_CODE (src) == LABEL_REF))))
--- 2666,2672 ----
  			|| REGNO (XEXP (src, 0)) == VIRTUAL_STACK_VARS_REGNUM)
  		    && CONSTANT_P (XEXP (src, 1)))
  		|| GET_CODE (src) == COMPARE
! 		|| CC0_P (dest)
  		|| (dest == pc_rtx
  		    && (src == pc_rtx || GET_CODE (src) == RETURN
  			|| GET_CODE (src) == LABEL_REF))))
*************** subst_constants (loc, insn, map, memonly
*** 2685,2694 ****
  	    if (compare_mode != VOIDmode
  		&& GET_CODE (src) == COMPARE
  		&& (GET_MODE_CLASS (GET_MODE (src)) == MODE_CC
! #ifdef HAVE_cc0
! 		    || dest == cc0_rtx
! #endif
! 		    )
  		&& GET_MODE (XEXP (src, 0)) == VOIDmode
  		&& GET_MODE (XEXP (src, 1)) == VOIDmode)
  	      {
--- 2680,2686 ----
  	    if (compare_mode != VOIDmode
  		&& GET_CODE (src) == COMPARE
  		&& (GET_MODE_CLASS (GET_MODE (src)) == MODE_CC
! 		    || CC0_P (dest))
  		&& GET_MODE (XEXP (src, 0)) == VOIDmode
  		&& GET_MODE (XEXP (src, 1)) == VOIDmode)
  	      {
Index: jump.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/jump.c,v
retrieving revision 1.216
diff -c -3 -p -r1.216 jump.c
*** jump.c	10 Jan 2003 13:44:28 -0000	1.216
--- jump.c	19 Jan 2003 15:26:02 -0000
*************** reversed_comparison_code_parts (code, ar
*** 701,711 ****
        break;
      }

!   if (GET_MODE_CLASS (mode) == MODE_CC
! #ifdef HAVE_cc0
!       || arg0 == cc0_rtx
! #endif
!       )
      {
        rtx prev;
        /* Try to search for the comparison to determine the real mode.
--- 701,707 ----
        break;
      }

!   if (GET_MODE_CLASS (mode) == MODE_CC || CC0_P (arg0))
      {
        rtx prev;
        /* Try to search for the comparison to determine the real mode.
Index: loop.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/loop.c,v
retrieving revision 1.437
diff -c -3 -p -r1.437 loop.c
*** loop.c	17 Jan 2003 03:28:08 -0000	1.437
--- loop.c	19 Jan 2003 15:26:03 -0000
***************
*** 1,6 ****
  /* Perform various loop optimizations, including strength reduction.
     Copyright (C) 1987, 1988, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
!    1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.

  This file is part of GCC.

--- 1,6 ----
  /* Perform various loop optimizations, including strength reduction.
     Copyright (C) 1987, 1988, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
!    1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.

  This file is part of GCC.

*************** canonicalize_condition (insn, cond, reve
*** 9444,9454 ****
  	}
      }

- #ifdef HAVE_cc0
    /* Never return CC0; return zero instead.  */
!   if (op0 == cc0_rtx)
      return 0;
- #endif

    return gen_rtx_fmt_ee (code, VOIDmode, op0, op1);
  }
--- 9444,9452 ----
  	}
      }

    /* Never return CC0; return zero instead.  */
!   if (CC0_P (op0))
      return 0;

    return gen_rtx_fmt_ee (code, VOIDmode, op0, op1);
  }
Index: simplify-rtx.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/simplify-rtx.c,v
retrieving revision 1.128
diff -c -3 -p -r1.128 simplify-rtx.c
*** simplify-rtx.c	24 Dec 2002 08:30:31 -0000	1.128
--- simplify-rtx.c	19 Jan 2003 15:26:04 -0000
***************
*** 1,6 ****
  /* RTL simplification functions for GNU compiler.
     Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
!    1999, 2000, 2001, 2002 Free Software Foundation, Inc.

  This file is part of GCC.

--- 1,6 ----
  /* RTL simplification functions for GNU compiler.
     Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
!    1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.

  This file is part of GCC.

*************** simplify_relational_operation (code, mod
*** 1860,1870 ****

    /* We can't simplify MODE_CC values since we don't know what the
       actual comparison is.  */
!   if (GET_MODE_CLASS (GET_MODE (op0)) == MODE_CC
! #ifdef HAVE_cc0
!       || op0 == cc0_rtx
! #endif
!       )
      return 0;

    /* Make sure the constant is second.  */
--- 1860,1866 ----

    /* We can't simplify MODE_CC values since we don't know what the
       actual comparison is.  */
!   if (GET_MODE_CLASS (GET_MODE (op0)) == MODE_CC || CC0_P (op0))
      return 0;

    /* Make sure the constant is second.  */

Roger
--
Roger Sayle,                         E-mail: roger@eyesopen.com
OpenEye Scientific Software,         WWW: http://www.eyesopen.com/
Suite 1107, 3600 Cerrillos Road,     Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507.         Fax: (+1) 505-473-0833



More information about the Gcc-patches mailing list