Only (IV - RC) is allowed for induction variables.
authorSebastian Buchwald <Sebastian.Buchwald@kit.edu>
Fri, 22 Jun 2012 17:43:37 +0000 (19:43 +0200)
committerSebastian Buchwald <Sebastian.Buchwald@kit.edu>
Fri, 22 Jun 2012 17:43:37 +0000 (19:43 +0200)
ir/opt/opt_osr.c

index bc63844..4463226 100644 (file)
@@ -760,8 +760,26 @@ static void classify_iv(scc *pscc, iv_env *env)
 
                next = e->next;
                switch (get_irn_opcode(irn)) {
-               case iro_Add:
                case iro_Sub:
+                       only_phi = 0;
+                       {
+                               ir_node    *left        = get_Sub_left(irn);
+                               node_entry *left_entry  = get_irn_ne(left, env);
+                               ir_node    *right       = get_Sub_right(irn);
+                               node_entry *right_entry = get_irn_ne(right, env);
+
+                               if (left_entry->pscc != e->pscc ||
+                                   (right_entry->pscc != e->pscc && !is_rc(right, header))) {
+                                       /*
+                                        * Not an induction variable.
+                                        * Region constant are only allowed on right hand side.
+                                        */
+                                       goto fail;
+                               }
+                       }
+                       break;
+
+               case iro_Add:
                        only_phi = 0;
                        /* fall through */
                case iro_Phi: