public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: Glen Nakamura <glen@imodulo.com>
To: nobody@gcc.gnu.org
Cc: gcc-prs@gcc.gnu.org,
Subject: Re: optimization/6822: GCC 3.1.1 - Internal compiler error in extract_insn, at recog.c:2132
Date: Tue, 28 May 2002 08:16:00 -0000	[thread overview]
Message-ID: <20020528145605.10437.qmail@sources.redhat.com> (raw)

The following reply was made to PR optimization/6822; it has been noted by GNATS.

From: Glen Nakamura <glen@imodulo.com>
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: Re: optimization/6822: GCC 3.1.1 - Internal compiler error in extract_insn, at recog.c:2132
Date: Tue, 28 May 2002 04:49:41 -1000

 --FL5UXtIhxfXey3p5
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6822
 
 2002-05-28  Glen Nakamura  <glen@imodulo.com>
 
 	* fold-const.c (fold): Modify the transformation of a comparison
 	against the highest or lowest integer value to adjust for the
 	previous transformation which converts 'X >= CST to X > (CST - 1)'
 	and 'X < CST to X <= (CST - 1)'.
 
 The patch allows the compiler to reduce unsigned X < ~0 to X != ~0.
 It also reduces unsigned X <= (~0 - 1) to X != ~0 which the original patch
 missed...  e.g. gcc.c-torture/execute/loop-2c.c execution,  -Os
 would fail again on i586-pc-linux-gnu if we changed:
 
   for (p = &a[b], i = b; --i < ~0; )
     *--p = i * 3 + o;
 
 to:
 
   for (p = &a[b], i = b; --i <= (~0 - 1); )
     *--p = i * 3 + o;
 
 With this patch, both cases should work...
 
 - Glen Nakamura
 
 
 --FL5UXtIhxfXey3p5
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename="fold.diff"
 
 Index: fold-const.c
 ===================================================================
 RCS file: /cvsroot/gcc/gcc/gcc/fold-const.c,v
 retrieving revision 1.185.2.2
 diff -c -3 -p -r1.185.2.2 fold-const.c
 *** fold-const.c	23 Apr 2002 23:20:00 -0000	1.185.2.2
 --- fold-const.c	27 May 2002 21:11:18 -0000
 *************** fold (expr)
 *** 6490,6496 ****
   	  }
         }
   
 !       /* Change X >= CST to X > (CST - 1) if CST is positive.  */
         if (TREE_CODE (arg1) == INTEGER_CST
   	  && TREE_CODE (arg0) != INTEGER_CST
   	  && tree_int_cst_sgn (arg1) > 0)
 --- 6490,6497 ----
   	  }
         }
   
 !       /* Change X >= CST to X > (CST - 1) and X < CST to X <= (CST - 1)
 ! 	 if CST is positive.  */
         if (TREE_CODE (arg1) == INTEGER_CST
   	  && TREE_CODE (arg0) != INTEGER_CST
   	  && tree_int_cst_sgn (arg1) > 0)
 *************** fold (expr)
 *** 6753,6777 ****
   		  return omit_one_operand (type,
   					   convert (type, integer_zero_node),
   					   arg0);
 - 		case GE_EXPR:
 - 		  TREE_SET_CODE (t, EQ_EXPR);
 - 		  break;
 - 
   		case LE_EXPR:
   		  return omit_one_operand (type,
   					   convert (type, integer_one_node),
   					   arg0);
 ! 		case LT_EXPR:
 ! 		  TREE_SET_CODE (t, NE_EXPR);
   		  break;
   
   		default:
   		  break;
   		}
   
   	    else if (TREE_INT_CST_HIGH (arg1) == -1
   		     && (TREE_INT_CST_LOW (arg1)
 ! 			 == ((unsigned HOST_WIDE_INT) 1 << (width - 1)))
   		     && ! TREE_UNSIGNED (TREE_TYPE (arg1)))
   	      switch (TREE_CODE (t))
   		{
 --- 6754,6796 ----
   		  return omit_one_operand (type,
   					   convert (type, integer_zero_node),
   					   arg0);
   		case LE_EXPR:
   		  return omit_one_operand (type,
   					   convert (type, integer_one_node),
   					   arg0);
 ! 
 ! 		/* The GE_EXPR and LT_EXPR cases are unnecessary because a
 ! 		   previous optimization converted X >= CST to X > (CST - 1)
 ! 		   and X < CST to X <= (CST - 1).  These two cases are handled
 ! 		   in the next switch statement.  */
 ! 
 ! 		default:
   		  break;
 + 		}
   
 + 	    else if (TREE_INT_CST_HIGH (arg1) == 0
 + 		&& (TREE_INT_CST_LOW (arg1)
 + 		    == ((unsigned HOST_WIDE_INT) 1 << (width - 1)) - 2)
 + 		&& ! TREE_UNSIGNED (TREE_TYPE (arg1)))
 + 	      switch (TREE_CODE (t))
 + 		{
 + 		case GT_EXPR:
 + 		  code = EQ_EXPR;
 + 		  arg1 = const_binop (PLUS_EXPR, arg1, integer_one_node, 0);
 + 		  t = build (code, type, TREE_OPERAND (t, 0), arg1);
 + 		  break;
 + 		case LE_EXPR:
 + 		  code = NE_EXPR;
 + 		  arg1 = const_binop (PLUS_EXPR, arg1, integer_one_node, 0);
 + 		  t = build (code, type, TREE_OPERAND (t, 0), arg1);
 + 		  break;
   		default:
   		  break;
   		}
   
   	    else if (TREE_INT_CST_HIGH (arg1) == -1
   		     && (TREE_INT_CST_LOW (arg1)
 ! 			 == ((unsigned HOST_WIDE_INT) -1 << (width - 1)))
   		     && ! TREE_UNSIGNED (TREE_TYPE (arg1)))
   	      switch (TREE_CODE (t))
   		{
 *************** fold (expr)
 *** 6780,6785 ****
 --- 6799,6805 ----
   					   convert (type, integer_zero_node),
   					   arg0);
   		case LE_EXPR:
 + 		  code = EQ_EXPR;
   		  TREE_SET_CODE (t, EQ_EXPR);
   		  break;
   
 *************** fold (expr)
 *** 6788,6793 ****
 --- 6808,6814 ----
   					   convert (type, integer_one_node),
   					   arg0);
   		case GT_EXPR:
 + 		  code = NE_EXPR;
   		  TREE_SET_CODE (t, NE_EXPR);
   		  break;
   
 *************** fold (expr)
 *** 6830,6847 ****
                     return omit_one_operand (type,
                                              convert (type, integer_zero_node),
                                              arg0);
 -                 case GE_EXPR:
 -                   TREE_SET_CODE (t, EQ_EXPR);
 -                   break;
 - 
                   case LE_EXPR:
                     return omit_one_operand (type,
                                              convert (type, integer_one_node),
                                              arg0);
 !                 case LT_EXPR:
 !                   TREE_SET_CODE (t, NE_EXPR);
                     break;
   
                   default:
                     break;
                   }
 --- 6851,6886 ----
                     return omit_one_operand (type,
                                              convert (type, integer_zero_node),
                                              arg0);
                   case LE_EXPR:
                     return omit_one_operand (type,
                                              convert (type, integer_one_node),
                                              arg0);
 ! 
 ! 		/* The GE_EXPR and LT_EXPR cases are unnecessary because a
 ! 		   previous optimization converted X >= CST to X > (CST - 1)
 ! 		   and X < CST to X <= (CST - 1).  These two cases are handled
 ! 		   in the next switch statement.  */
 ! 
 !                 default:
                     break;
 +                 }
   
 +             else if (TREE_INT_CST_HIGH (arg1) == 0
 + 		     && (TREE_INT_CST_LOW (arg1)
 + 			 == ((unsigned HOST_WIDE_INT) 2 << (width - 1)) - 2)
 + 		     && TREE_UNSIGNED (TREE_TYPE (arg1)))
 +               switch (TREE_CODE (t))
 +                 {
 +                 case GT_EXPR:
 +                   code = EQ_EXPR;
 +                   arg1 = const_binop (PLUS_EXPR, arg1, integer_one_node, 0);
 +                   t = build (code, type, TREE_OPERAND (t, 0), arg1);
 +                   break;
 +                 case LE_EXPR:
 +                   code = NE_EXPR;
 +                   arg1 = const_binop (PLUS_EXPR, arg1, integer_one_node, 0);
 +                   t = build (code, type, TREE_OPERAND (t, 0), arg1);
 +                   break;
                   default:
                     break;
                   }
 
 --FL5UXtIhxfXey3p5--


             reply	other threads:[~2002-05-28 14:56 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-05-28  8:16 Glen Nakamura [this message]
  -- strict thread matches above, loose matches on Subject: below --
2002-06-02 13:06 Glen Nakamura
2002-06-02 12:36 Richard Henderson
2002-05-30 16:56 rth
2002-05-29 12:16 Richard Henderson
2002-05-29 10:36 Richard Henderson
2002-05-29  9:44 Glen Nakamura
2002-05-29  9:16 Eric Botcazou
2002-05-29  0:46 Glen Nakamura
2002-05-28 18:16 Glen Nakamura
2002-05-28 17:16 Eric Botcazou
2002-05-28 16:36 Eric Botcazou
2002-05-28 11:00 Richard Henderson
2002-05-28  7:10 Glen Nakamura
2002-05-26 16:46 paolo
2002-05-26 12:26 glen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020528145605.10437.qmail@sources.redhat.com \
    --to=glen@imodulo.com \
    --cc=gcc-prs@gcc.gnu.org \
    --cc=nobody@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).