aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-math-opts.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/tree-ssa-math-opts.cc')
-rw-r--r--gcc/tree-ssa-math-opts.cc48
1 files changed, 44 insertions, 4 deletions
diff --git a/gcc/tree-ssa-math-opts.cc b/gcc/tree-ssa-math-opts.cc
index 486bdbf..eb03ebe 100644
--- a/gcc/tree-ssa-math-opts.cc
+++ b/gcc/tree-ssa-math-opts.cc
@@ -2800,7 +2800,17 @@ convert_mult_to_widen (gimple *stmt, gimple_stmt_iterator *gsi)
return false;
if (actual_precision != TYPE_PRECISION (type1)
|| from_unsigned1 != TYPE_UNSIGNED (type1))
- type1 = build_nonstandard_integer_type (actual_precision, from_unsigned1);
+ {
+ if (!useless_type_conversion_p (type1, TREE_TYPE (rhs1)))
+ {
+ if (TREE_CODE (rhs1) == INTEGER_CST)
+ rhs1 = fold_convert (type1, rhs1);
+ else
+ rhs1 = build_and_insert_cast (gsi, loc, type1, rhs1);
+ }
+ type1 = build_nonstandard_integer_type (actual_precision,
+ from_unsigned1);
+ }
if (!useless_type_conversion_p (type1, TREE_TYPE (rhs1)))
{
if (TREE_CODE (rhs1) == INTEGER_CST)
@@ -2810,7 +2820,17 @@ convert_mult_to_widen (gimple *stmt, gimple_stmt_iterator *gsi)
}
if (actual_precision != TYPE_PRECISION (type2)
|| from_unsigned2 != TYPE_UNSIGNED (type2))
- type2 = build_nonstandard_integer_type (actual_precision, from_unsigned2);
+ {
+ if (!useless_type_conversion_p (type2, TREE_TYPE (rhs2)))
+ {
+ if (TREE_CODE (rhs2) == INTEGER_CST)
+ rhs2 = fold_convert (type2, rhs2);
+ else
+ rhs2 = build_and_insert_cast (gsi, loc, type2, rhs2);
+ }
+ type2 = build_nonstandard_integer_type (actual_precision,
+ from_unsigned2);
+ }
if (!useless_type_conversion_p (type2, TREE_TYPE (rhs2)))
{
if (TREE_CODE (rhs2) == INTEGER_CST)
@@ -3021,7 +3041,17 @@ convert_plusminus_to_widen (gimple_stmt_iterator *gsi, gimple *stmt,
actual_precision = GET_MODE_PRECISION (actual_mode);
if (actual_precision != TYPE_PRECISION (type1)
|| from_unsigned1 != TYPE_UNSIGNED (type1))
- type1 = build_nonstandard_integer_type (actual_precision, from_unsigned1);
+ {
+ if (!useless_type_conversion_p (type1, TREE_TYPE (mult_rhs1)))
+ {
+ if (TREE_CODE (mult_rhs1) == INTEGER_CST)
+ mult_rhs1 = fold_convert (type1, mult_rhs1);
+ else
+ mult_rhs1 = build_and_insert_cast (gsi, loc, type1, mult_rhs1);
+ }
+ type1 = build_nonstandard_integer_type (actual_precision,
+ from_unsigned1);
+ }
if (!useless_type_conversion_p (type1, TREE_TYPE (mult_rhs1)))
{
if (TREE_CODE (mult_rhs1) == INTEGER_CST)
@@ -3031,7 +3061,17 @@ convert_plusminus_to_widen (gimple_stmt_iterator *gsi, gimple *stmt,
}
if (actual_precision != TYPE_PRECISION (type2)
|| from_unsigned2 != TYPE_UNSIGNED (type2))
- type2 = build_nonstandard_integer_type (actual_precision, from_unsigned2);
+ {
+ if (!useless_type_conversion_p (type2, TREE_TYPE (mult_rhs2)))
+ {
+ if (TREE_CODE (mult_rhs2) == INTEGER_CST)
+ mult_rhs2 = fold_convert (type2, mult_rhs2);
+ else
+ mult_rhs2 = build_and_insert_cast (gsi, loc, type2, mult_rhs2);
+ }
+ type2 = build_nonstandard_integer_type (actual_precision,
+ from_unsigned2);
+ }
if (!useless_type_conversion_p (type2, TREE_TYPE (mult_rhs2)))
{
if (TREE_CODE (mult_rhs2) == INTEGER_CST)