+2011-08-19 Andrew Stubbs <ams@codesourcery.com>
+
+ * tree-ssa-math-opts.c (is_widening_mult_rhs_p): Handle constants
+ beyond conversions.
+ (convert_mult_to_widen): Convert constant inputs to the right type.
+ (convert_plusminus_to_widen): Don't automatically reject inputs that
+ are not an SSA_NAME.
+ Convert constant inputs to the right type.
+
2011-08-19 Andrew Stubbs <ams@codesourcery.com>
* tree-ssa-math-opts.c (convert_plusminus_to_widen): Convert add_rhs
: rhs_code != FIXED_CONVERT_EXPR)
rhs1 = rhs;
else
- rhs1 = gimple_assign_rhs1 (stmt);
+ {
+ rhs1 = gimple_assign_rhs1 (stmt);
+
+ if (TREE_CODE (rhs1) == INTEGER_CST)
+ {
+ *new_rhs_out = rhs1;
+ *type_out = NULL;
+ return true;
+ }
+ }
}
else
rhs1 = rhs;
rhs2 = build_and_insert_cast (gsi, loc, tmp, rhs2);
}
+ /* Handle constants. */
+ if (TREE_CODE (rhs1) == INTEGER_CST)
+ rhs1 = fold_convert (type1, rhs1);
+ if (TREE_CODE (rhs2) == INTEGER_CST)
+ rhs2 = fold_convert (type2, rhs2);
+
gimple_assign_set_rhs1 (stmt, rhs1);
gimple_assign_set_rhs2 (stmt, rhs2);
gimple_assign_set_rhs_code (stmt, WIDEN_MULT_EXPR);
if (is_gimple_assign (rhs1_stmt))
rhs1_code = gimple_assign_rhs_code (rhs1_stmt);
}
- else
- return false;
if (TREE_CODE (rhs2) == SSA_NAME)
{
if (is_gimple_assign (rhs2_stmt))
rhs2_code = gimple_assign_rhs_code (rhs2_stmt);
}
- else
- return false;
/* Allow for one conversion statement between the multiply
and addition/subtraction statement. If there are more than
add_rhs = build_and_insert_cast (gsi, loc, create_tmp_var (type, NULL),
add_rhs);
+ /* Handle constants. */
+ if (TREE_CODE (mult_rhs1) == INTEGER_CST)
+ rhs1 = fold_convert (type1, mult_rhs1);
+ if (TREE_CODE (mult_rhs2) == INTEGER_CST)
+ rhs2 = fold_convert (type2, mult_rhs2);
+
gimple_assign_set_rhs_with_ops_1 (gsi, wmult_code, mult_rhs1, mult_rhs2,
add_rhs);
update_stmt (gsi_stmt (*gsi));