This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [4.7 regression?] HImode 'smax' RTL generation


On 14 March 2012 11:48, Richard Guenther <richard.guenther@gmail.com> wrote:
> On Wed, Mar 14, 2012 at 11:39 AM, Frederic Riss <frederic.riss@gmail.com> wrote:
>> Doing that at expansion time looks like papering over some other issue though.
>
> Can you check where the COND_EXPR is introduced? ?That place should
> be fixed to properly fold.

Quite logically it's the if-conversion that generates the COND_EXPRs.
The following patch tries to fold if-converted stmts right after their
creation; it fixes my test-case but hasn't undergone any other
validation:

diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c
index ca9503f..59fc162 100644
--- a/gcc/tree-if-conv.c
+++ b/gcc/tree-if-conv.c
@@ -1278,6 +1278,7 @@ predicate_scalar_phi (gimple phi, tree cond,
   gimple new_stmt;
   basic_block bb;
   tree rhs, res, arg, scev;
+  gimple_stmt_iterator new_gsi;

   gcc_assert (gimple_code (phi) == GIMPLE_PHI
              && gimple_phi_num_args (phi) == 2);
@@ -1322,6 +1323,11 @@ predicate_scalar_phi (gimple phi, tree cond,
   new_stmt = gimple_build_assign (res, rhs);
   SSA_NAME_DEF_STMT (gimple_phi_result (phi)) = new_stmt;
   gsi_insert_before (gsi, new_stmt, GSI_SAME_STMT);
+  if (arg != rhs) {
+    /* COND_EXPR might fold to {MIN,MAX}_EXPR.  */
+    new_gsi = gsi_for_stmt (new_stmt);
+    fold_stmt (&new_gsi);
+  }
   update_stmt (new_stmt);

   if (dump_file && (dump_flags & TDF_DETAILS))


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]