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]
Other format: [Raw text]

PATCH: gcc-3_2-branch (PR 7829 and 7695)


The canonicalize_condition function in loop.c rewrites ordered
comparison with integers involving equality to use strict comparisons
instead. In oder to do that, it adds or subtracts one from the integer
constant participating into comparison. When doing so, it sometimes
creates integer constants which are not correct for their intended
modes. For instance, when incrementing QImode 127, it creates a new
constant 0x80. insn_recog then fails to recognize any insns which use
this constant, because if expects sign extended 0xFFFFFF80 value
instead. The following simple function demonstrates the problem and
will cause GCC version 3.1, 3.1.1, 3.2, as well as latest gcc-3_2-branch
snapshot to die with ICE:

static unsigned int
gbkext1_mbtowc (unsigned char c1, unsigned char c2)
{
  return  c1 + (c2 - (c2 >= 0x80 ? 0x41 : 0x40));
}

The GCC trunk has this bug fixed in rev. 1.398 of gcc/loop.c. I applied
this patch to GCC 3.2 released version and 3.2.1 snapshot and
successfully bootstrapped both on i386-unknown-freebsd4.7 and
i386-unknown-freebsd5.0.

--
Alexander Kabaev

2002-09-09  Alexander Kabaev  <kan@FreeBSD.ORG>
 	Move from mainline.
 	* loop.c (canonicalize_condition): Use gen_int_mode.

Patch move as expressed with cvs commands:

cvs update -j1.397 -j1.398 loop.c

Patch move as expressed in standard gcc mailing list format:

Index: loop.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/loop.c,v
retrieving revision 1.389.2.7
diff -c -r1.389.2.7 loop.c
*** loop.c	15 Jun 2002 01:12:04 -0000	1.389.2.7
--- loop.c	9 Sep 2002 20:23:19 -0000
***************
*** 9264,9270 ****
  	{
  	case LE:
  	  if ((unsigned HOST_WIDE_INT) const_val != max_val >> 1)
! 	    code = LT, op1 = GEN_INT (const_val + 1);
  	  break;
  
  	/* When cross-compiling, const_val might be sign-extended from
--- 9264,9270 ----
  	{
  	case LE:
  	  if ((unsigned HOST_WIDE_INT) const_val != max_val >> 1)
! 	    code = LT, op1 = gen_int_mode (const_val + 1, GET_MODE (op0));
  	  break;
  
  	/* When cross-compiling, const_val might be sign-extended from
***************
*** 9273,9289 ****
  	  if ((HOST_WIDE_INT) (const_val & max_val)
  	      != (((HOST_WIDE_INT) 1
  		   << (GET_MODE_BITSIZE (GET_MODE (op0)) - 1))))
! 	    code = GT, op1 = GEN_INT (const_val - 1);
  	  break;
  
  	case LEU:
  	  if (uconst_val < max_val)
! 	    code = LTU, op1 = GEN_INT (uconst_val + 1);
  	  break;
  
  	case GEU:
  	  if (uconst_val != 0)
! 	    code = GTU, op1 = GEN_INT (uconst_val - 1);
  	  break;
  
  	default:
--- 9273,9289 ----
  	  if ((HOST_WIDE_INT) (const_val & max_val)
  	      != (((HOST_WIDE_INT) 1
  		   << (GET_MODE_BITSIZE (GET_MODE (op0)) - 1))))
! 	    code = GT, op1 = gen_int_mode (const_val - 1, GET_MODE (op0));
  	  break;
  
  	case LEU:
  	  if (uconst_val < max_val)
! 	    code = LTU, op1 = gen_int_mode (uconst_val + 1, GET_MODE (op0));
  	  break;
  
  	case GEU:
  	  if (uconst_val != 0)
! 	    code = GTU, op1 = gen_int_mode (uconst_val - 1, GET_MODE (op0));
  	  break;
  
  	default:


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