]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Add MULT_HIGHPART_EXPR
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 27 Jun 2012 21:30:51 +0000 (21:30 +0000)
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 27 Jun 2012 21:30:51 +0000 (21:30 +0000)
        * tree.def (MULT_HIGHPART_EXPR): New.
        * cfgexpand.c (expand_debug_expr): Ignore it.
        * expr.c (expand_expr_real_2): Handle it.
        * fold-const.c (int_const_binop_1): Likewise.
        * optabs.c (optab_for_tree_code): Likewise.
        * tree-cfg.c (verify_gimple_assign_binary): Likewise.
        * tree-inline.c (estimate_operator_cost): Likewise.
        * tree-pretty-print.c (dump_generic_node): Likewise.
        (op_code_prio, op_symbol_code): Likewise.
        * tree.c (commutative_tree_code): Likewise.  Also handle
        WIDEN_MULT_EXPR, VEC_WIDEN_MULT_HI_EXPR, VEC_WIDEN_MULT_LO_EXPR.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@189027 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/cfgexpand.c
gcc/expr.c
gcc/fold-const.c
gcc/optabs.c
gcc/tree-cfg.c
gcc/tree-inline.c
gcc/tree-pretty-print.c
gcc/tree.c
gcc/tree.def

index 344c2987dec887e60c923e91c260dcea2aaebe39..8720ec49d00c9d49cc307aea68086d59e85af491 100644 (file)
@@ -1,3 +1,17 @@
+2012-06-27  Richard Henderson  <rth@redhat.com>
+
+       * tree.def (MULT_HIGHPART_EXPR): New.
+       * cfgexpand.c (expand_debug_expr): Ignore it.
+       * expr.c (expand_expr_real_2): Handle it.
+       * fold-const.c (int_const_binop_1): Likewise.
+       * optabs.c (optab_for_tree_code): Likewise.
+       * tree-cfg.c (verify_gimple_assign_binary): Likewise.
+       * tree-inline.c (estimate_operator_cost): Likewise.
+       * tree-pretty-print.c (dump_generic_node): Likewise.
+       (op_code_prio, op_symbol_code): Likewise.
+       * tree.c (commutative_tree_code): Likewise.  Also handle
+       WIDEN_MULT_EXPR, VEC_WIDEN_MULT_HI_EXPR, VEC_WIDEN_MULT_LO_EXPR.
+
 2012-06-27  Richard Henderson  <rth@redhat.com>
 
        PR target/53749
index a8397c69b039dc62f93dd8c317b7cae780b6b53a..ad2f66738cccbd1fd59c49d7f13f61a492f3dbc4 100644 (file)
@@ -3415,7 +3415,7 @@ expand_debug_expr (tree exp)
     case VEC_PERM_EXPR:
       return NULL;
 
-   /* Misc codes.  */
+    /* Misc codes.  */
     case ADDR_SPACE_CONVERT_EXPR:
     case FIXED_CONVERT_EXPR:
     case OBJ_TYPE_REF:
@@ -3466,6 +3466,10 @@ expand_debug_expr (tree exp)
        }
       return NULL;
 
+    case MULT_HIGHPART_EXPR:
+      /* ??? Similar to the above.  */
+      return NULL;
+
     case WIDEN_SUM_EXPR:
     case WIDEN_LSHIFT_EXPR:
       if (SCALAR_INT_MODE_P (GET_MODE (op0))
index cad5b10b6b0f4f1b52b4e25cd84f0fc89748ffec..5295da2149caebabe378079711b26c3274176197 100644 (file)
@@ -8551,6 +8551,7 @@ expand_expr_real_2 (sepops ops, rtx target, enum machine_mode tmode,
       return expand_divmod (0, code, mode, op0, op1, target, unsignedp);
 
     case RDIV_EXPR:
+    case MULT_HIGHPART_EXPR:
       goto binop;
 
     case TRUNC_MOD_EXPR:
index 877cf32717e700eadcfc2a495d2f894729ae50e3..702f4e06701d2fe8e4906d34df7634462fdd0e15 100644 (file)
@@ -999,6 +999,16 @@ int_const_binop_1 (enum tree_code code, const_tree arg1, const_tree arg2,
                             &res.low, &res.high);
       break;
 
+    case MULT_HIGHPART_EXPR:
+      /* ??? Need quad precision, or an additional shift operand
+        to the multiply primitive, to handle very large highparts.  */
+      if (TYPE_PRECISION (type) > HOST_BITS_PER_WIDE_INT)
+       return NULL_TREE;
+      tmp = double_int_mul (op1, op2);
+      res = double_int_rshift (tmp, TYPE_PRECISION (type),
+                              TYPE_PRECISION (type), !uns);
+      break;
+
     case TRUNC_DIV_EXPR:
     case FLOOR_DIV_EXPR: case CEIL_DIV_EXPR:
     case EXACT_DIV_EXPR:
index 9a549ff066776501ec49c825b7c6d5c63c524006..30944765e5f9b71203ecf5cd28caf44532a2ddb7 100644 (file)
@@ -367,6 +367,9 @@ optab_for_tree_code (enum tree_code code, const_tree type,
     case BIT_XOR_EXPR:
       return xor_optab;
 
+    case MULT_HIGHPART_EXPR:
+      return TYPE_UNSIGNED (type) ? umul_highpart_optab : smul_highpart_optab;
+
     case TRUNC_MOD_EXPR:
     case CEIL_MOD_EXPR:
     case FLOOR_MOD_EXPR:
index d7ab090fe4b6b45b31f5e80350b56cb5b8ac1e00..fe5af704cf860bb965a035e5b86395927cbeb82d 100644 (file)
@@ -3731,6 +3731,7 @@ do_pointer_plus_expr_check:
       return false;
 
     case MULT_EXPR:
+    case MULT_HIGHPART_EXPR:
     case TRUNC_DIV_EXPR:
     case CEIL_DIV_EXPR:
     case FLOOR_DIV_EXPR:
index 6746296ddadf94b0a451976ee8f14ffb0c24fac0..c3d3fb6648600c4aac7fe4d096c6f5f86bd28da4 100644 (file)
@@ -3379,6 +3379,7 @@ estimate_operator_cost (enum tree_code code, eni_weights *weights,
     case POINTER_PLUS_EXPR:
     case MINUS_EXPR:
     case MULT_EXPR:
+    case MULT_HIGHPART_EXPR:
     case FMA_EXPR:
 
     case ADDR_SPACE_CONVERT_EXPR:
index f810d772d594970a9f6c175bd4196cf64b9abb8d..44d3c10b7d81a19b33195cd9e7f19ba8e5df0384 100644 (file)
@@ -1612,6 +1612,7 @@ dump_generic_node (pretty_printer *buffer, tree node, int spc, int flags,
     case WIDEN_SUM_EXPR:
     case WIDEN_MULT_EXPR:
     case MULT_EXPR:
+    case MULT_HIGHPART_EXPR:
     case PLUS_EXPR:
     case POINTER_PLUS_EXPR:
     case MINUS_EXPR:
@@ -2674,6 +2675,7 @@ op_code_prio (enum tree_code code)
     case WIDEN_MULT_PLUS_EXPR:
     case WIDEN_MULT_MINUS_EXPR:
     case MULT_EXPR:
+    case MULT_HIGHPART_EXPR:
     case TRUNC_DIV_EXPR:
     case CEIL_DIV_EXPR:
     case FLOOR_DIV_EXPR:
@@ -2852,6 +2854,9 @@ op_symbol_code (enum tree_code code)
     case WIDEN_MULT_EXPR:
       return "w*";
 
+    case MULT_HIGHPART_EXPR:
+      return "h*";
+
     case NEGATE_EXPR:
     case MINUS_EXPR:
       return "-";
index d3c2a19d7d6f0ac0770cde8c3ab834a1e5909f45..1717d713698b44cad68542a2adee002dc169d3b9 100644 (file)
@@ -6899,6 +6899,7 @@ commutative_tree_code (enum tree_code code)
     {
     case PLUS_EXPR:
     case MULT_EXPR:
+    case MULT_HIGHPART_EXPR:
     case MIN_EXPR:
     case MAX_EXPR:
     case BIT_IOR_EXPR:
@@ -6913,6 +6914,9 @@ commutative_tree_code (enum tree_code code)
     case TRUTH_AND_EXPR:
     case TRUTH_XOR_EXPR:
     case TRUTH_OR_EXPR:
+    case WIDEN_MULT_EXPR:
+    case VEC_WIDEN_MULT_HI_EXPR:
+    case VEC_WIDEN_MULT_LO_EXPR:
       return true;
 
     default:
index 8a3007cd47be0d0d7f2c776267c051f295334983..b0d4aead470217507fd1effb29bc29f6ce83d9a2 100644 (file)
@@ -639,6 +639,10 @@ DEFTREECODE (MULT_EXPR, "mult_expr", tcc_binary, 2)
    second operand is an integer of type sizetype.  */
 DEFTREECODE (POINTER_PLUS_EXPR, "pointer_plus_expr", tcc_binary, 2)
 
+/* Highpart multiplication.  For an integral type with precision B,
+   returns bits [2B-1, B] of the full 2*B product.  */
+DEFTREECODE (MULT_HIGHPART_EXPR, "mult_highpart_expr", tcc_binary, 2)
+
 /* Division for integer result that rounds the quotient toward zero.  */
 DEFTREECODE (TRUNC_DIV_EXPR, "trunc_div_expr", tcc_binary, 2)