fixed DBG_OPT_RAW() call
[libfirm] / ir / opt / ldstopt.c
index 663ff5f..d535879 100644 (file)
@@ -339,7 +339,6 @@ static compound_graph_path *get_accessed_path(ir_node *ptr) {
   return rec_get_accessed_path(ptr, 0);
 }
 
-
 /**
  * optimize a Load
  */
@@ -366,7 +365,7 @@ static int optimize_load(ir_node *load)
     if (get_irn_op(ptr) == op_Sel) {
       ir_node *mem = get_Sel_mem(ptr);
 
-      if (get_irn_op(mem) == op_Alloc) {
+      if (get_irn_op(skip_Proj(mem)) == op_Alloc) {
         /* ok, check the types */
         entity *ent  = get_Sel_entity(ptr);
         type *s_type = get_entity_type(ent);
@@ -381,7 +380,8 @@ static int optimize_load(ir_node *load)
         }
       }
     }
-    else if (get_irn_op(ptr) == op_Alloc) {
+    else if ((get_irn_op(skip_Proj(ptr)) == op_Alloc) ||
+            ((get_irn_op(ptr) == op_Cast) && (get_irn_op(skip_Proj(get_Cast_op(ptr))) == op_Alloc))) {
       /* simple case: a direct load after an Alloc. Firm Alloc throw
        * an exception in case of out-of-memory. So, there is no way for an
        * exception in this load.
@@ -549,8 +549,10 @@ static int optimize_load(ir_node *load)
        */
       if ((!pred_info->projs[pn_Store_X_except] && !info->projs[pn_Load_X_except]) ||
           get_nodes_block(load) == get_nodes_block(pred)) {
-        DBG_OPT_RAW(load, pred);
-        exchange( info->projs[pn_Load_res], get_Store_value(pred) );
+        ir_node *value = get_Store_value(pred);
+
+        DBG_OPT_RAW(load, value);
+        exchange(info->projs[pn_Load_res], value);
 
         if (info->projs[pn_Load_M])
           exchange(info->projs[pn_Load_M], mem);