Added insertion of duplicates for operands of phi nodes that interfere
[libfirm] / ir / be / sp_matrix.c
index 1a3f495..665dd60 100644 (file)
@@ -1,17 +1,26 @@
 /**
+ * Author:      Daniel Grund
+ * Date:               07.04.2005
+ * Copyright:   (c) Universitaet Karlsruhe
+ * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
+
  * Sparse matrix storage with linked lists for rows and cols.
  * I did not need floats, so this is all integer.
- * @author Daniel Grund
- * @date 07.04.2005
  */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
+#ifdef HAVE_ALLOCA_H
+#include <alloca.h>
+#endif
+#ifdef HAVE_MALLOC_H
+#include <malloc.h>
+#endif
+
 #include <stdio.h>
 #include <stdlib.h>
-#include <alloca.h>
 #include <assert.h>
 #include "sp_matrix.h"
 #include "list.h"
@@ -72,7 +81,7 @@ static INLINE int _m_new_size(int old_size, int min) {
 
 /**
  * Allocates space for @p count entries in the rows array and
- * intitializes all entries from @p start to the end.
+ * inititializes all entries from @p start to the end.
  */
 static INLINE void _m_alloc_row(sp_matrix_t *m, int start, int count) {
        int p;
@@ -88,7 +97,7 @@ static INLINE void _m_alloc_row(sp_matrix_t *m, int start, int count) {
 
 /**
  * Allocates space for @p count entries in the cols array and
- * intitializes all entries from @p start to the end.
+ * inititializes all entries from @p start to the end.
  */
 static INLINE void _m_alloc_col(sp_matrix_t *m, int start, int count) {
        int p;
@@ -332,8 +341,10 @@ void matrix_optimize(sp_matrix_t *m) {
 
        /* kill all double-entries (Mij and Mji are set) */
        matrix_foreach(m, e) {
+    int t_val;
+
                assert(e->row != e->col && "Root has itself as arg. Ok. But the arg (=root) will alwazs have the same color as root");
-               int t_val = matrix_get(m, e->col, e->row);
+               t_val = matrix_get(m, e->col, e->row);
                if (t_val) {
                        matrix_set(m, e->col, e->row, 0);
                        matrix_set(m, e->row, e->col, e->val + t_val);