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] Use optab_for_tree_code


This patch tweaks the expander to use the new optab_for_tree_code function I introduced for the vector patch.

Bootstrapped/regtested i686-pc-linux-gnu, ok for mainline?

Paolo
2004-07-22  Paolo Bonzini  <bonzini@gnu.org>

	* expr.c (expand_expr_real): Instead of setting
	this_optab, use optab_for_tree_code at the binop2
	label; sole exception is MULT_EXPR, for which we
	use a new binop3 label which accepts a previously
	set this_optab.
	* optabs.c (optab_for_tree_code): Handle logical
	operations on truth values.

Index: expr.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/expr.c,v
retrieving revision 1.688
diff -u -r1.688 expr.c
--- expr.c	21 Jul 2004 19:23:02 -0000	1.688
+++ expr.c	22 Jul 2004 10:55:47 -0000
@@ -7326,10 +7326,6 @@
       return op0;
 
     case PLUS_EXPR:
-      this_optab = ! unsignedp && flag_trapv
-                   && (GET_MODE_CLASS (mode) == MODE_INT)
-                   ? addv_optab : add_optab;
-
       /* If we are adding a constant, a VAR_DECL that is sp, fp, or ap, and
 	 something else, make sure we add the register to the constant and
 	 then to the other thing.  This case can occur during strength
@@ -7464,10 +7460,6 @@
 	    return REDUCE_BIT_FIELD (gen_rtx_MINUS (mode, op0, op1));
 	}
 
-      this_optab = ! unsignedp && flag_trapv
-                   && (GET_MODE_CLASS(mode) == MODE_INT)
-                   ? subv_optab : sub_optab;
-
       /* No sense saving up arithmetic to be done
 	 if it's all in the wrong mode to form part of an address.
 	 And force_operand won't know whether to sign-extend or
@@ -7571,7 +7563,7 @@
 		    expand_operands (TREE_OPERAND (TREE_OPERAND (exp, 0), 0),
 				     TREE_OPERAND (TREE_OPERAND (exp, 1), 0),
 				     NULL_RTX, &op0, &op1, 0);
-		  goto binop2;
+		  goto binop3;
 		}
 	      else if (other_optab->handlers[(int) mode].insn_code != CODE_FOR_nothing
 		       && innermode == word_mode)
@@ -7629,7 +7621,6 @@
 					  build_real (type, dconst1),
 					  TREE_OPERAND (exp, 1))),
 			    target, tmode, modifier);
-      this_optab = sdiv_optab;
       goto binop;
 
     case TRUNC_MOD_EXPR:
@@ -7672,9 +7664,8 @@
       if (modifier == EXPAND_STACK_PARM)
 	target = 0;
       temp = expand_unop (mode,
-			  ! unsignedp && flag_trapv
-			  && (GET_MODE_CLASS(mode) == MODE_INT)
-			  ? negv_optab : neg_optab, op0, target, 0);
+      			  optab_for_tree_code (NEGATE_EXPR, type),
+			  op0, target, 0);
       if (temp == 0)
 	abort ();
       return REDUCE_BIT_FIELD (temp);
@@ -7713,10 +7704,7 @@
       /* First try to do it with a special MIN or MAX instruction.
 	 If that does not win, use a conditional jump to select the proper
 	 value.  */
-      this_optab = (unsignedp
-		    ? (code == MIN_EXPR ? umin_optab : umax_optab)
-		    : (code == MIN_EXPR ? smin_optab : smax_optab));
-
+      this_optab = optab_for_tree_code (code, type);
       temp = expand_binop (mode, this_optab, op0, op1, target, unsignedp,
 			   OPTAB_WIDEN);
       if (temp != 0)
@@ -7786,17 +7774,10 @@
 
     case TRUTH_AND_EXPR:
     case BIT_AND_EXPR:
-      this_optab = and_optab;
-      goto binop;
-
     case TRUTH_OR_EXPR:
     case BIT_IOR_EXPR:
-      this_optab = ior_optab;
-      goto binop;
-
     case TRUTH_XOR_EXPR:
     case BIT_XOR_EXPR:
-      this_optab = xor_optab;
       goto binop;
 
     case LSHIFT_EXPR:
@@ -8106,14 +8087,8 @@
 	  {
 	    rtx result;
 	    tree cond;
-	    optab boptab = (TREE_CODE (binary_op) == PLUS_EXPR
-			    ? (TYPE_TRAP_SIGNED (TREE_TYPE (binary_op))
-			       ? addv_optab : add_optab)
-			    : TREE_CODE (binary_op) == MINUS_EXPR
-			    ? (TYPE_TRAP_SIGNED (TREE_TYPE (binary_op))
-			       ? subv_optab : sub_optab)
-			    : TREE_CODE (binary_op) == BIT_IOR_EXPR ? ior_optab
-			    : xor_optab);
+      	    optab boptab = optab_for_tree_code (TREE_CODE (binary_op),
+						TREE_TYPE (binary_op));
 
 	    /* If we had X ? A : A + 1, do this as A + (X == 0).  */
 	    if (singleton == TREE_OPERAND (exp, 1))
@@ -8632,12 +8567,13 @@
 				     modifier, alt_rtl);
     }
 
-  /* Here to do an ordinary binary operator, generating an instruction
-     from the optab already placed in `this_optab'.  */
+  /* Here to do an ordinary binary operator.  */
  binop:
   expand_operands (TREE_OPERAND (exp, 0), TREE_OPERAND (exp, 1),
 		   subtarget, &op0, &op1, 0);
  binop2:
+  this_optab = optab_for_tree_code (code, type);
+ binop3:
   if (modifier == EXPAND_STACK_PARM)
     target = 0;
   temp = expand_binop (mode, this_optab, op0, op1, target,
Index: optabs.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/optabs.c,v
retrieving revision 1.231
diff -u -r1.231 optabs.c
--- optabs.c	22 Jul 2004 08:20:35 -0000	1.231
+++ optabs.c	22 Jul 2004 10:55:48 -0000
@@ -639,15 +245,18 @@
   bool trapv;
   switch (code)
     {
+    case TRUTH_AND_EXPR:
     case BIT_AND_EXPR:
       return and_optab;
 
+    case TRUTH_OR_EXPR:
     case BIT_IOR_EXPR:
       return ior_optab;
 
     case BIT_NOT_EXPR:
       return one_cmpl_optab;
 
+    case TRUTH_XOR_EXPR:
     case BIT_XOR_EXPR:
       return xor_optab;
 

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