remove unneeded limit register

This commit is contained in:
Jörg Thalheim 2013-12-13 10:36:19 +01:00
parent b7399b014b
commit 588ee8b710
3 changed files with 34 additions and 31 deletions

View File

@ -52,8 +52,8 @@
\begin{lstlisting}
typedef uint32_t u32;
void heron_sqrt(u32 *mem) {
int i;
for (i = 1; i <= mem[0]; i++){
int i = mem[0];
while (i > 0) {
u32 s = mem[i];
if (s > 1) {
// x_0 = (s + 1) / 2
@ -71,6 +71,7 @@ void heron_sqrt(u32 *mem) {
}
mem[i] = x;
}
i--;
}
}
\end{lstlisting}

View File

@ -2,19 +2,17 @@
digraph heron {
//node [shape=circle,regular=1,style=filled,fillcolor=white];
edge [arrowhead=odot];
graph [overlap=false];
graph [overlap=scale];
subgraph {
edge [weight=3];
C0 -> C1 -> C2 -> C3 -> C4 -> C5 -> C6 -> C7 -> C8 -> C9
C0 -> C1 -> C2 -> C3 -> C4 -> C5 -> C6 -> C7 -> C8 -> C9 [minlen=3.5];
}
// variables & constants
mem_0 [label="mem[0]"];
mem_i [label="mem[i]"];
mem_i2 [label="mem[i]"];
i [ ];
mem_i2 [label="mem[i]",shape="box"];
i [label="i"];
1 [ ];
"1a" [label="1" ];
"1b" [label="1" ];
@ -23,30 +21,32 @@ digraph heron {
Finish [label="Finish"];
// operands
s_shift_1 [label=">>",];
i_lte_mem_0 [label=">=",];
s_shift_1 [label=">>",];
i_lt_0 [label=">",];
// i <= mem[0]
mem_0 -> i_lte_mem_0;
i -> i_lte_mem_0;
{ rank=same; C1; i_lte_mem_0; }
{ rank=same; C0; i; mem_0;}
mem_0 -> i:n [label="C0",style=dotted];
0 -> i_lt_0;
i -> i_lt_0;
{ rank=same; C0; i}
{ rank=same; C1; i_lt_0; }
// if (i <= mem[0]) ->
i_lte_mem_0 -> mem_s_gte_1 [style=dotted, arrowhead=normal,label="True",lhead=cluster_i_lte_mem_0];
i_lt_0 -> mem_s_gte_1 [style=dotted, arrowhead=normal,label="True"];
// else
i_lte_mem_0 -> Finish [style=dotted, arrowhead=normal,label="False",lhead=cluster_i_lte_mem_0];
i_lt_0 -> Finish [style=dotted, arrowhead=normal,label="False"];
{ rank=same; C9; Finish;}
subgraph i_lte_mem_0 {
subgraph i_lt_0 {
mem_s_gte_1 [label=">"];
s_div_x [label="/",];
new_x [label="+",];
s_div_x_shift_1 [label=">>",];
x_shift_1 [label=">>",];
old_x_lte_new_x [label="¹>=",];
inc_i [label="+",];
old_x_lte_new_x [label=">=",];
dec_i [label="-",];
// (s > 1)
mem_i -> mem_s_gte_1;
@ -56,16 +56,17 @@ digraph heron {
// if (s > 1)
mem_s_gte_1 -> s_shift_1 [style=dotted,arrowhead=normal,label="True"];
// else
mem_s_gte_1 -> inc_i [style=dotted,arrowhead=normal,label="False"];
mem_s_gte_1 -> dec_i [style=dotted,arrowhead=normal,label="False"];
subgraph if_mem_i_gte_1 {
// x = s >> 1
mem_i -> s_shift_1;
1 -> s_shift_1;
s_shift_1 -> x;
s_shift_1 -> x [style=dotted,arrowhead=normal,label="C2->C3"];
{ rank=same; C3; s_shift_1; x}
// (x >> 1)
x [shape="box"];
x -> x_shift_1;
"1a" -> x_shift_1;
// (s/x)
@ -86,20 +87,20 @@ digraph heron {
// (old_x <= X)
x -> old_x_lte_new_x;
new_x -> old_x_lte_new_x;
new_x -> x [style=dotted,label="if(¹)"];
new_x -> x [style=dotted,label="C7->C3"];
{ rank=same; C7; old_x_lte_new_x;}
// if (old_x <= X)
old_x_lte_new_x -> inc_i [style=dotted,arrowhead=normal,label="True"];
old_x_lte_new_x -> dec_i [style=dotted,arrowhead=normal,label="True"];
// else
old_x_lte_new_x -> x [style=dotted,arrowhead=normal,label="False"];
"1c" -> inc_i;
i -> inc_i:ne;
inc_i:s -> i:s;
new_x -> mem_i2 [label="if(¹)", style=dotted];
{ rank=same; C8; inc_i; mem_i2};
"1c" -> dec_i;
i -> dec_i:ne;
dec_i:s -> i:s;
new_x -> mem_i2 [label="C7->C8", style=dotted];
{ rank=same; C8; dec_i; mem_i2};
}
}
}

5
sqrt.c
View File

@ -7,8 +7,8 @@
typedef uint32_t u32;
void heron_sqrt(u32 *mem) {
int i;
for (i = 1; i <= mem[0]; i++){
int i = mem[0];
while (i > 0) {
u32 s = mem[i];
if (s > 1) {
// x_0 = (s + 1) / 2
@ -26,6 +26,7 @@ void heron_sqrt(u32 *mem) {
}
mem[i] = x;
}
i--;
}
}