From: Bin Cheng Date: Thu, 11 May 2017 09:33:49 +0000 (+0000) Subject: tree-ssa-loop-ivopts.c (force_expr_to_var_cost): Handle more operators... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c544114fdece1611ab623e71483118c962047b29;p=gcc.git tree-ssa-loop-ivopts.c (force_expr_to_var_cost): Handle more operators... * tree-ssa-loop-ivopts.c (force_expr_to_var_cost): Handle more operators: TRUNC_DIV_EXPR, BIT_AND_EXPR, BIT_IOR_EXPR, LSHIFT_EXPR, RSHIFT_EXPR and BIT_NOT_EXPR. From-SVN: r247886 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2004b24d0c9..e39c09d565d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-05-11 Bin Cheng + + * tree-ssa-loop-ivopts.c (force_expr_to_var_cost): Handle more + operators: TRUNC_DIV_EXPR, BIT_AND_EXPR, BIT_IOR_EXPR, LSHIFT_EXPR, + RSHIFT_EXPR and BIT_NOT_EXPR. + 2017-05-11 Bin Cheng * tree-ssa-loop-ivopts.c (get_loop_invariant_expr): Simplify. diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 43cab302a5c..4fc0ba4a5db 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -4080,6 +4080,11 @@ force_expr_to_var_cost (tree expr, bool speed) case PLUS_EXPR: case MINUS_EXPR: case MULT_EXPR: + case TRUNC_DIV_EXPR: + case BIT_AND_EXPR: + case BIT_IOR_EXPR: + case LSHIFT_EXPR: + case RSHIFT_EXPR: op0 = TREE_OPERAND (expr, 0); op1 = TREE_OPERAND (expr, 1); STRIP_NOPS (op0); @@ -4088,6 +4093,7 @@ force_expr_to_var_cost (tree expr, bool speed) CASE_CONVERT: case NEGATE_EXPR: + case BIT_NOT_EXPR: op0 = TREE_OPERAND (expr, 0); STRIP_NOPS (op0); op1 = NULL_TREE; @@ -4156,6 +4162,23 @@ force_expr_to_var_cost (tree expr, bool speed) return comp_cost (target_spill_cost [speed], 0); break; + case TRUNC_DIV_EXPR: + /* Division by power of two is usually cheap, so we allow it. Forbid + anything else. */ + if (integer_pow2p (TREE_OPERAND (expr, 1))) + cost = comp_cost (add_cost (speed, mode), 0); + else + cost = comp_cost (target_spill_cost[speed], 0); + break; + + case BIT_AND_EXPR: + case BIT_IOR_EXPR: + case BIT_NOT_EXPR: + case LSHIFT_EXPR: + case RSHIFT_EXPR: + cost = comp_cost (add_cost (speed, mode), 0); + break; + default: gcc_unreachable (); }