rcuja: 2d distribution sum improvement
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 6 Jun 2013 15:59:16 +0000 (11:59 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 6 Jun 2013 15:59:16 +0000 (11:59 -0400)
Perform inner loop in 2 checks instead of 4.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
rcuja/rcuja.c

index c6095956ab14f23e20227f8f05b8b317ce65646f..a608dd7c4797e534339f64ab841c054492f7e00e 100644 (file)
@@ -1091,17 +1091,18 @@ void ja_node_sum_distribution_2d(enum ja_recompact mode,
                                continue;
                        for (bit_i = 0; bit_i < JA_BITS_PER_BYTE; bit_i++) {
                                for (bit_j = 0; bit_j < bit_i; bit_j++) {
-                                       if ((v & (1U << bit_i)) && (v & (1U << bit_j))) {
-                                               nr_2d_11[bit_i][bit_j]++;
-                                       }
-                                       if ((v & (1U << bit_i)) && !(v & (1U << bit_j))) {
-                                               nr_2d_10[bit_i][bit_j]++;
-                                       }
-                                       if (!(v & (1U << bit_i)) && (v & (1U << bit_j))) {
-                                               nr_2d_01[bit_i][bit_j]++;
-                                       }
-                                       if (!(v & (1U << bit_i)) && !(v & (1U << bit_j))) {
-                                               nr_2d_00[bit_i][bit_j]++;
+                                       if (v & (1U << bit_i)) {
+                                               if (v & (1U << bit_j)) {
+                                                       nr_2d_11[bit_i][bit_j]++;
+                                               } else {
+                                                       nr_2d_10[bit_i][bit_j]++;
+                                               }
+                                       } else {
+                                               if (v & (1U << bit_j)) {
+                                                       nr_2d_01[bit_i][bit_j]++;
+                                               } else {
+                                                       nr_2d_00[bit_i][bit_j]++;
+                                               }
                                        }
                                }
                        }
@@ -1133,17 +1134,18 @@ void ja_node_sum_distribution_2d(enum ja_recompact mode,
                                        continue;
                                for (bit_i = 0; bit_i < JA_BITS_PER_BYTE; bit_i++) {
                                        for (bit_j = 0; bit_j < bit_i; bit_j++) {
-                                               if ((v & (1U << bit_i)) && (v & (1U << bit_j))) {
-                                                       nr_2d_11[bit_i][bit_j]++;
-                                               }
-                                               if ((v & (1U << bit_i)) && !(v & (1U << bit_j))) {
-                                                       nr_2d_10[bit_i][bit_j]++;
-                                               }
-                                               if (!(v & (1U << bit_i)) && (v & (1U << bit_j))) {
-                                                       nr_2d_01[bit_i][bit_j]++;
-                                               }
-                                               if (!(v & (1U << bit_i)) && !(v & (1U << bit_j))) {
-                                                       nr_2d_00[bit_i][bit_j]++;
+                                               if (v & (1U << bit_i)) {
+                                                       if (v & (1U << bit_j)) {
+                                                               nr_2d_11[bit_i][bit_j]++;
+                                                       } else {
+                                                               nr_2d_10[bit_i][bit_j]++;
+                                                       }
+                                               } else {
+                                                       if (v & (1U << bit_j)) {
+                                                               nr_2d_01[bit_i][bit_j]++;
+                                                       } else {
+                                                               nr_2d_00[bit_i][bit_j]++;
+                                                       }
                                                }
                                        }
                                }
@@ -1167,17 +1169,18 @@ void ja_node_sum_distribution_2d(enum ja_recompact mode,
                                continue;
                        for (bit_i = 0; bit_i < JA_BITS_PER_BYTE; bit_i++) {
                                for (bit_j = 0; bit_j < bit_i; bit_j++) {
-                                       if ((i & (1U << bit_i)) && (i & (1U << bit_j))) {
-                                               nr_2d_11[bit_i][bit_j]++;
-                                       }
-                                       if ((i & (1U << bit_i)) && !(i & (1U << bit_j))) {
-                                               nr_2d_10[bit_i][bit_j]++;
-                                       }
-                                       if (!(i & (1U << bit_i)) && (i & (1U << bit_j))) {
-                                               nr_2d_01[bit_i][bit_j]++;
-                                       }
-                                       if (!(i & (1U << bit_i)) && !(i & (1U << bit_j))) {
-                                               nr_2d_00[bit_i][bit_j]++;
+                                       if (i & (1U << bit_i)) {
+                                               if (i & (1U << bit_j)) {
+                                                       nr_2d_11[bit_i][bit_j]++;
+                                               } else {
+                                                       nr_2d_10[bit_i][bit_j]++;
+                                               }
+                                       } else {
+                                               if (i & (1U << bit_j)) {
+                                                       nr_2d_01[bit_i][bit_j]++;
+                                               } else {
+                                                       nr_2d_00[bit_i][bit_j]++;
+                                               }
                                        }
                                }
                        }
@@ -1196,17 +1199,18 @@ void ja_node_sum_distribution_2d(enum ja_recompact mode,
        if (mode == JA_RECOMPACT_ADD_NEXT || mode == JA_RECOMPACT_ADD_SAME) {
                for (bit_i = 0; bit_i < JA_BITS_PER_BYTE; bit_i++) {
                        for (bit_j = 0; bit_j < bit_i; bit_j++) {
-                               if ((n & (1U << bit_i)) && (n & (1U << bit_j))) {
-                                       nr_2d_11[bit_i][bit_j]++;
-                               }
-                               if ((n & (1U << bit_i)) && !(n & (1U << bit_j))) {
-                                       nr_2d_10[bit_i][bit_j]++;
-                               }
-                               if (!(n & (1U << bit_i)) && (n & (1U << bit_j))) {
-                                       nr_2d_01[bit_i][bit_j]++;
-                               }
-                               if (!(n & (1U << bit_i)) && !(n & (1U << bit_j))) {
-                                       nr_2d_00[bit_i][bit_j]++;
+                               if (n & (1U << bit_i)) {
+                                       if (n & (1U << bit_j)) {
+                                               nr_2d_11[bit_i][bit_j]++;
+                                       } else {
+                                               nr_2d_10[bit_i][bit_j]++;
+                                       }
+                               } else {
+                                       if (n & (1U << bit_j)) {
+                                               nr_2d_01[bit_i][bit_j]++;
+                                       } else {
+                                               nr_2d_00[bit_i][bit_j]++;
+                                       }
                                }
                        }
                }
This page took 0.035098 seconds and 4 git commands to generate.