patch to fold-const.c

Chandra Chavva cchavva@cygnus.com
Tue May 30 15:53:00 GMT 2000


Hi,

The following testcase fails while comparing the signed value with 
unsigned value. Here is the patch which fixes this problem. Okay to apply.
This is failing with gcc version 2.9-gnupro-99r1 under solaris platform 
and also for mips target.

void    main(void)
{
    int         is = -32768 ;
    unsigned int    iu = 0 ;
    unsigned int    ua ;

    ua = ( iu >= is ) ? iu : is ;

    if( ua == is ) 
        exit (0);
    abort ();
}

Here is the patch

	* fold-const.c (fold): Convert to proper type before reducing the
	depth of the tree.

Index: fold-const.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/fold-const.c,v
retrieving revision 1.148
diff -p -r1.148 fold-const.c
*** fold-const.c        2000/01/13 03:59:35     1.148
--- fold-const.c        2000/05/30 22:51:38
*************** fold (expr) 
*** 5809,5815 ****
          && (! FLOAT_TYPE_P (type)
              || (flag_fast_math && code == MULT_EXPR)))
        {
!         t = reduce_expression_tree_depth (code, type, arg0, arg1);
          code = TREE_CODE (t);
          arg0 = TREE_OPERAND (t, 0);
          arg1 = TREE_OPERAND (t, 1);
--- 5809,5817 ----
          && (! FLOAT_TYPE_P (type)
              || (flag_fast_math && code == MULT_EXPR)))
        {
!         t = reduce_expression_tree_depth (code, type,
!                                           convert (type, arg0),
!                                           convert (type, arg1));
          code = TREE_CODE (t);
          arg0 = TREE_OPERAND (t, 0);
          arg1 = TREE_OPERAND (t, 1);







More information about the Gcc-patches mailing list