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] Simplify the comparison of rtx against -1, 0, and 1.


Hi,

Attached is a patch to simplify the comparison of rtx against -1, 0, and 1.

Tested on i686-pc-linux-gnu.  Committed as obvious.

Kazu Hirata

2003-07-22  Kazu Hirata  <kazu@cs.umass.edu>

	* combine.c (if_then_else_cond): Simplify the comparison of
	rtx against -1, 0, and 1.
	* loop.c (check_dbra_loop): Likewise.
	* optabs.c (emit_conditional_move): Likewise.
	(emit_conditional_add): Likewise.
	* config/i386/i386.md (*movsi_or): Likewise.
	(*movdi_or_rex6): Likewise.

Index: combine.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/combine.c,v
retrieving revision 1.373
diff -u -p -r1.373 combine.c
--- combine.c	19 Jul 2003 14:47:00 -0000	1.373
+++ combine.c	22 Jul 2003 00:15:24 -0000
@@ -7345,7 +7345,7 @@ if_then_else_cond (rtx x, rtx *ptrue, rt
 
   /* If we are comparing a value against zero, we are done.  */
   if ((code == NE || code == EQ)
-      && GET_CODE (XEXP (x, 1)) == CONST_INT && INTVAL (XEXP (x, 1)) == 0)
+      && XEXP (x, 1) == const0_rtx)
     {
       *ptrue = (code == NE) ? const_true_rtx : const0_rtx;
       *pfalse = (code == NE) ? const0_rtx : const_true_rtx;
Index: loop.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/loop.c,v
retrieving revision 1.466
diff -u -p -r1.466 loop.c
--- loop.c	19 Jul 2003 14:47:07 -0000	1.466
+++ loop.c	22 Jul 2003 00:15:30 -0000
@@ -8034,9 +8034,7 @@ check_dbra_loop (struct loop *loop, int 
      In this case, add a reg_note REG_NONNEG, which allows the
      m68k DBRA instruction to be used.  */
 
-  if (((GET_CODE (comparison) == GT
-	&& GET_CODE (XEXP (comparison, 1)) == CONST_INT
-	&& INTVAL (XEXP (comparison, 1)) == -1)
+  if (((GET_CODE (comparison) == GT && XEXP (comparison, 1) == constm1_rtx)
        || (GET_CODE (comparison) == NE && XEXP (comparison, 1) == const0_rtx))
       && GET_CODE (bl->biv->add_val) == CONST_INT
       && INTVAL (bl->biv->add_val) < 0)
Index: optabs.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/optabs.c,v
retrieving revision 1.186
diff -u -p -r1.186 optabs.c
--- optabs.c	19 Jul 2003 14:47:07 -0000	1.186
+++ optabs.c	22 Jul 2003 00:15:32 -0000
@@ -4259,9 +4259,9 @@ emit_conditional_move (rtx target, enum 
   /* get_condition will prefer to generate LT and GT even if the old
      comparison was against zero, so undo that canonicalization here since
      comparisons against zero are cheaper.  */
-  if (code == LT && GET_CODE (op1) == CONST_INT && INTVAL (op1) == 1)
+  if (code == LT && op1 == const1_rtx)
     code = LE, op1 = const0_rtx;
-  else if (code == GT && GET_CODE (op1) == CONST_INT && INTVAL (op1) == -1)
+  else if (code == GT && op1 == constm1_rtx)
     code = GE, op1 = const0_rtx;
 
   if (cmode == VOIDmode)
@@ -4400,9 +4400,9 @@ emit_conditional_add (rtx target, enum r
   /* get_condition will prefer to generate LT and GT even if the old
      comparison was against zero, so undo that canonicalization here since
      comparisons against zero are cheaper.  */
-  if (code == LT && GET_CODE (op1) == CONST_INT && INTVAL (op1) == 1)
+  if (code == LT && op1 == const1_rtx)
     code = LE, op1 = const0_rtx;
-  else if (code == GT && GET_CODE (op1) == CONST_INT && INTVAL (op1) == -1)
+  else if (code == GT && op1 == constm1_rtx)
     code = GE, op1 = const0_rtx;
 
   if (cmode == VOIDmode)
Index: config/i386/i386.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.md,v
retrieving revision 1.478
diff -u -p -r1.478 i386.md
--- config/i386/i386.md	9 Jul 2003 02:56:47 -0000	1.478
+++ config/i386/i386.md	22 Jul 2003 00:15:38 -0000
@@ -1166,8 +1166,8 @@
   [(set (match_operand:SI 0 "register_operand" "=r")
 	(match_operand:SI 1 "immediate_operand" "i"))
    (clobber (reg:CC 17))]
-  "reload_completed && GET_CODE (operands[1]) == CONST_INT
-   && INTVAL (operands[1]) == -1
+  "reload_completed
+   && operands[1] == constm1_rtx
    && (TARGET_PENTIUM || optimize_size)"
 {
   operands[1] = constm1_rtx;
@@ -1930,8 +1930,7 @@
    (clobber (reg:CC 17))]
   "TARGET_64BIT && (TARGET_PENTIUM || optimize_size)
    && reload_completed
-   && GET_CODE (operands[1]) == CONST_INT
-   && INTVAL (operands[1]) == -1"
+   && operands[1] == constm1_rtx"
 {
   operands[1] = constm1_rtx;
   return "or{q}\t{%1, %0|%0, %1}";


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