tree-ssa-forwprop.c (forward_propagate_into_comparison): Do not make the replacement...
authorEric Botcazou <ebotcazou@adacore.com>
Sun, 9 Oct 2011 21:39:12 +0000 (21:39 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Sun, 9 Oct 2011 21:39:12 +0000 (21:39 +0000)
* tree-ssa-forwprop.c (forward_propagate_into_comparison): Do not make
the replacement if the conversion to the LHS type is not useless.

From-SVN: r179730

gcc/ChangeLog
gcc/tree-ssa-forwprop.c

index 925b62577e02f6f8733b9e25b52ff7861fcf2d80..3a3c9853a16eee31a086e734b79828bfad51dd91 100644 (file)
@@ -1,3 +1,8 @@
+2011-10-09  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * tree-ssa-forwprop.c (forward_propagate_into_comparison): Do not make
+       the replacement if the conversion to the LHS type is not useless.
+
 2011-10-09  Ira Rosen  <ira.rosen@linaro.org>
 
        PR tree-optimization/50635
index a8737dac933ada0d28dd71466bde645c3b04d033..de782c9be9f3f189123acb0991b3044ed9f56dbf 100644 (file)
@@ -465,16 +465,15 @@ forward_propagate_into_comparison (gimple_stmt_iterator *gsi)
   gimple stmt = gsi_stmt (*gsi);
   tree tmp;
   bool cfg_changed = false;
+  tree type = TREE_TYPE (gimple_assign_lhs (stmt));
   tree rhs1 = gimple_assign_rhs1 (stmt);
   tree rhs2 = gimple_assign_rhs2 (stmt);
 
   /* Combine the comparison with defining statements.  */
   tmp = forward_propagate_into_comparison_1 (stmt,
                                             gimple_assign_rhs_code (stmt),
-                                            TREE_TYPE
-                                              (gimple_assign_lhs (stmt)),
-                                            rhs1, rhs2);
-  if (tmp)
+                                            type, rhs1, rhs2);
+  if (tmp && useless_type_conversion_p (type, TREE_TYPE (tmp)))
     {
       gimple_assign_set_rhs_from_tree (gsi, tmp);
       fold_stmt (gsi);