+2017-05-11 Bin Cheng <bin.cheng@arm.com>
+
+ * 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 <bin.cheng@arm.com>
* tree-ssa-loop-ivopts.c (get_loop_invariant_expr): Simplify.
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);
CASE_CONVERT:
case NEGATE_EXPR:
+ case BIT_NOT_EXPR:
op0 = TREE_OPERAND (expr, 0);
STRIP_NOPS (op0);
op1 = NULL_TREE;
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 ();
}