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] Optimize MINUS_EXPR jump (PR middle-end/21237)


	When constructing a comparison for MINUS_EXPR, do_jump() currently
builds a NE_EXPR and directly calls do_compare_and_jump().  This inhibits
an optimization opportunity to split a NE_EXPR comparison into parts if it
is too wide to be compared with one insn.  do_compare_and_jump() generates
a libcall for wide comparisons.

	The appended patch changes the MINUS_EXPR case to build the
revised expression and then fall through to NE_EXPR, which has the logic
to choose comparison and jump by parts.

Okay for mainline?

Thanks, David


	PR middle-end/21237
	* dojump.c (do_jump, MINUS_EXPR): Build NE_EXPR and fall through
	to NE_EXPR case.

Index: dojump.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/dojump.c,v
retrieving revision 1.39
diff -c -p -r1.39 dojump.c
*** dojump.c	27 Apr 2005 16:02:30 -0000	1.39
--- dojump.c	8 May 2005 20:23:24 -0000
*************** do_jump (tree exp, rtx if_false_label, r
*** 207,220 ****
        do_jump (TREE_OPERAND (exp, 0), if_false_label, if_true_label);
        break;
  
-     case MINUS_EXPR:
-       /* Nonzero iff operands of minus differ.  */
-       do_compare_and_jump (build2 (NE_EXPR, TREE_TYPE (exp),
- 				   TREE_OPERAND (exp, 0),
- 				   TREE_OPERAND (exp, 1)),
-                            NE, NE, if_false_label, if_true_label);
-       break;
- 
      case BIT_AND_EXPR:
        /* fold_single_bit_test() converts (X & (1 << C)) into (X >> C) & 1.
  	 See if the former is preferred for jump tests and restore it
--- 207,212 ----
*************** do_jump (tree exp, rtx if_false_label, r
*** 369,374 ****
--- 361,372 ----
          break;
        }
  
+     case MINUS_EXPR:
+       /* Nonzero iff operands of minus differ.  */
+       exp = build2 (NE_EXPR, TREE_TYPE (exp),
+ 		    TREE_OPERAND (exp, 0),
+ 		    TREE_OPERAND (exp, 1));
+       /* FALLTHRU */
      case NE_EXPR:
        {
          tree inner_type = TREE_TYPE (TREE_OPERAND (exp, 0));


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