🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #350

Re: FIX FOR: gcc 2.1 post increment bug

#350
From: Chip Salzenberg
Date: Thu, 09 Apr 1992 21:21
74 lines
2880 bytes
A bug report from brennan@baker.ds.boeing.COM shows that, under
optimization, "switch (*p++)" may branch to the wrong case in the
switch.  Here is a patch.

----------------------------------------------------------------------------
Thu Apr  9 09:50:26 1992  Chip Salzenberg  (chip at tct.com)

	* stmt.c (expand_end_case): Before using index expression,
	  take care to call copy_to_reg() and protect_from_queue().

Index: stmt.c
*************** expand_end_case (orig_index)
*** 3582,3591 ****
  	    }
  
  	  emit_queue ();
  	  do_pending_stack_adjust ();
  
- 	  index = protect_from_queue (index, 0);
- 	  if (GET_CODE (index) == MEM)
- 	    index = copy_to_reg (index);
  	  if (GET_CODE (index) == CONST_INT
  	      || TREE_CODE (index_expr) == INTEGER_CST)
--- 3582,3591 ----
  	    }
  
+ 	  if (GET_CODE (index) == MEM)
+ 	    index = copy_to_reg (index);
+ 	  index = protect_from_queue (index, 0);
  	  emit_queue ();
  	  do_pending_stack_adjust ();
  
  	  if (GET_CODE (index) == CONST_INT
  	      || TREE_CODE (index_expr) == INTEGER_CST)
*************** expand_end_case (orig_index)
*** 3662,3667 ****
  				      index_expr);
  	      index = expand_expr (index_expr, 0, VOIDmode, 0);
! 	      emit_queue ();
  	      index = protect_from_queue (index, 0);
  	      do_pending_stack_adjust ();
  
--- 3662,3671 ----
  				      index_expr);
  	      index = expand_expr (index_expr, 0, VOIDmode, 0);
! 
! 
! 	      if (GET_CODE (index) == MEM)
! 		index = copy_to_reg (index);
  	      index = protect_from_queue (index, 0);
+ 	      emit_queue ();
  	      do_pending_stack_adjust ();
  
*************** expand_end_case (orig_index)
*** 3681,3686 ****
  	      index = expand_expr (index_expr, 0, VOIDmode, 0);
  	      index = convert_to_mode (Pmode, index, 1);
! 	      emit_queue ();
  	      index = protect_from_queue (index, 0);
  	      do_pending_stack_adjust ();
  
--- 3685,3693 ----
  	      index = expand_expr (index_expr, 0, VOIDmode, 0);
  	      index = convert_to_mode (Pmode, index, 1);
! 
! 	      if (GET_CODE (index) == MEM)
! 		index = copy_to_reg (index);
  	      index = protect_from_queue (index, 0);
+ 	      emit_queue ();
  	      do_pending_stack_adjust ();
  
-- 
Chip Salzenberg at Teltronics/TCT  <chip@tct.com>, <73717.366@compuserve.com>
      "Informix 4GL is not a 4G, and it's barely an L."  -- John Tombs
Technical Details
Message-ID: <m0lZ6YP-0006weC@tct.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!tct.COM!chip
References: <9204011927.AA23117@baker.ds.boeing.com>

Show Full Headers
Complete Article Headers
Newsgroups: gnu.gcc.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!tct.COM!chip
From: chip@tct.COM (Chip Salzenberg)
Subject: Re: FIX FOR: gcc 2.1 post increment bug
Message-ID: <m0lZ6YP-0006weC@tct.com>
Sender: gnulists@ai.mit.edu
Organization: TC Telemanagement, Clearwater, FL
References: <9204011927.AA23117@baker.ds.boeing.com>
Distribution: gnu
Date: Thu, 9 Apr 1992 21:21:00 GMT
Approved: bug-gcc@prep.ai.mit.edu
Lines: 75