diff options
author | Richard Sandiford <rdsandiford@googlemail.com> | 2010-07-31 15:51:17 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2010-07-31 15:51:17 +0000 |
commit | 9eab7f91b9147d721680a49a5e07c8c0f2b4d2af (patch) | |
tree | 823f82a89dd1d28b19a663287f60b3b0ae52a5d4 | |
parent | 6601202c2980c23c590355619ba82d540e50a0ae (diff) | |
download | gcc-9eab7f91b9147d721680a49a5e07c8c0f2b4d2af.zip gcc-9eab7f91b9147d721680a49a5e07c8c0f2b4d2af.tar.gz gcc-9eab7f91b9147d721680a49a5e07c8c0f2b4d2af.tar.bz2 |
tree-ssa-math-opts.c (convert_plusminus_to_widen): Fix type used in the call to optab_for_tree_code.
gcc/
* tree-ssa-math-opts.c (convert_plusminus_to_widen): Fix type
used in the call to optab_for_tree_code. Fix the second
is_widening_mult_p call. Check that both unwidened operands
have the same sign.
From-SVN: r162784
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/tree-ssa-math-opts.c | 31 |
2 files changed, 25 insertions, 13 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 250eb86..3b3d4bf 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2010-07-31 Richard Sandiford <rdsandiford@googlemail.com> + + * tree-ssa-math-opts.c (convert_plusminus_to_widen): Fix type + used in the call to optab_for_tree_code. Fix the second + is_widening_mult_p call. Check that both unwidened operands + have the same sign. + 2010-07-31 John Tytgat <John.Tytgat@aaug.net> * config/arm/arm.c (arm_function_arg): Remove superfluous test. diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c index 9b96a60..bf37b77 100644 --- a/gcc/tree-ssa-math-opts.c +++ b/gcc/tree-ssa-math-opts.c @@ -1414,13 +1414,6 @@ convert_plusminus_to_widen (gimple_stmt_iterator *gsi, gimple stmt, else wmult_code = WIDEN_MULT_PLUS_EXPR; - /* Verify that the machine can perform a widening multiply - accumulate in this mode/signedness combination, otherwise - this transformation is likely to pessimize code. */ - this_optab = optab_for_tree_code (wmult_code, type, optab_default); - if (optab_handler (this_optab, TYPE_MODE (type)) == CODE_FOR_nothing) - return false; - rhs1 = gimple_assign_rhs1 (stmt); rhs2 = gimple_assign_rhs2 (stmt); @@ -1447,37 +1440,49 @@ convert_plusminus_to_widen (gimple_stmt_iterator *gsi, gimple stmt, if (!is_widening_mult_p (rhs1_stmt, &type1, &mult_rhs1, &type2, &mult_rhs2)) return false; - mult_rhs1 = fold_convert (type1, mult_rhs1); - mult_rhs2 = fold_convert (type2, mult_rhs2); add_rhs = rhs2; } else if (rhs2_code == MULT_EXPR) { - if (!is_widening_mult_p (rhs1_stmt, &type1, &mult_rhs1, + if (!is_widening_mult_p (rhs2_stmt, &type1, &mult_rhs1, &type2, &mult_rhs2)) return false; - mult_rhs1 = fold_convert (type1, mult_rhs1); - mult_rhs2 = fold_convert (type2, mult_rhs2); add_rhs = rhs1; } else if (code == PLUS_EXPR && rhs1_code == WIDEN_MULT_EXPR) { mult_rhs1 = gimple_assign_rhs1 (rhs1_stmt); mult_rhs2 = gimple_assign_rhs2 (rhs1_stmt); + type1 = TREE_TYPE (mult_rhs1); + type2 = TREE_TYPE (mult_rhs2); add_rhs = rhs2; } else if (rhs2_code == WIDEN_MULT_EXPR) { mult_rhs1 = gimple_assign_rhs1 (rhs2_stmt); mult_rhs2 = gimple_assign_rhs2 (rhs2_stmt); + type1 = TREE_TYPE (mult_rhs1); + type2 = TREE_TYPE (mult_rhs2); add_rhs = rhs1; } else return false; + if (TYPE_UNSIGNED (type1) != TYPE_UNSIGNED (type2)) + return false; + + /* Verify that the machine can perform a widening multiply + accumulate in this mode/signedness combination, otherwise + this transformation is likely to pessimize code. */ + this_optab = optab_for_tree_code (wmult_code, type1, optab_default); + if (optab_handler (this_optab, TYPE_MODE (type)) == CODE_FOR_nothing) + return false; + /* ??? May need some type verification here? */ - gimple_assign_set_rhs_with_ops_1 (gsi, wmult_code, mult_rhs1, mult_rhs2, + gimple_assign_set_rhs_with_ops_1 (gsi, wmult_code, + fold_convert (type1, mult_rhs1), + fold_convert (type2, mult_rhs2), add_rhs); update_stmt (gsi_stmt (*gsi)); return true; |