Merger of git branch "gimple-classes-v2-option-3"
[gcc.git] / gcc / tree-ssa-loop-unswitch.c
index 8a0f10a6c5418fd19a7d60c93a5e2f6726867f7b..bad33ae435cc52ef013147749fa5132e7c91e6a5 100644 (file)
@@ -148,15 +148,17 @@ tree_ssa_unswitch_loops (void)
 static tree
 tree_may_unswitch_on (basic_block bb, struct loop *loop)
 {
-  gimple stmt, def;
+  gimple last, def;
+  gcond *stmt;
   tree cond, use;
   basic_block def_bb;
   ssa_op_iter iter;
 
   /* BB must end in a simple conditional jump.  */
-  stmt = last_stmt (bb);
-  if (!stmt || gimple_code (stmt) != GIMPLE_COND)
+  last = last_stmt (bb);
+  if (!last || gimple_code (last) != GIMPLE_COND)
     return NULL_TREE;
+  stmt = as_a <gcond *> (last);
 
   /* To keep the things simple, we do not directly remove the conditions,
      but just replace tests with 0 != 0 resp. 1 != 0.  Prevent the infinite
@@ -258,13 +260,15 @@ tree_unswitch_single_loop (struct loop *loop, int num)
       if (integer_nonzerop (cond))
        {
          /* Remove false path.  */
-         gimple_cond_set_condition_from_tree (stmt, boolean_true_node);
+         gimple_cond_set_condition_from_tree (as_a <gcond *> (stmt),
+                                              boolean_true_node);
          changed = true;
        }
       else if (integer_zerop (cond))
        {
          /* Remove true path.  */
-         gimple_cond_set_condition_from_tree (stmt, boolean_false_node);
+         gimple_cond_set_condition_from_tree (as_a <gcond *> (stmt),
+                                              boolean_false_node);
          changed = true;
        }
       /* Do not unswitch too much.  */
@@ -326,9 +330,10 @@ tree_unswitch_single_loop (struct loop *loop, int num)
              if (stmt
                  && gimple_code (stmt) == GIMPLE_COND)
                {
-                 if (gimple_cond_true_p (stmt))
+                 gcond *cond_stmt = as_a <gcond *> (stmt);
+                 if (gimple_cond_true_p (cond_stmt))
                    flags = EDGE_FALSE_VALUE;
-                 else if (gimple_cond_false_p (stmt))
+                 else if (gimple_cond_false_p (cond_stmt))
                    flags = EDGE_TRUE_VALUE;
                }
            }