ping...

I do not want to push, but could you at least tell me if you are
going to look at this problem and the fix I propose?

I am sure you do not need my explanations, but let me provide more
details about the problem and the (simple!) fix I sent just in case.

Lets start from the very beginning. The compilation of this trivial
program

        one = 1 : route(1,1,1,1);
        process = route(1,1,1,one);

fails with the "invalid route" errmsg. Despite the fact that "one"
is the compile time constant == 1 !!!

Why? because the isBoxRoute() case in realeval() gets something like

        cons(1,cons(SigBinOp(0,0,1),nil))

in 'lsr' after boxPropagateSig/etc and after that sigList2vecInt(lsr)
fails because it expects that all elements in this tree shoud be
isSigInt() or isSigReal(), while without simplification this SigBinOp()
is not, even if this SigBinOp(0 /*kAdd*/, 0,1) is just 0 + 1 == 1.

Where does this sigBinOp(kAdd) come from? From another isBoxRoute()
case in realPropagate(). This code fills the "outsigs" array with
zeroes first, then it does

        outsigs[dst] = sigAdd(outsigs[dst], lsig[src]);

when we have both the destination and the source.

Why? I guess because route() sums all the signals which go to the same
route/destination and this makes a lot of sense (to be honest I didn't
know about this feauture until I have looked at this code ;)

Now. We can simply change the code above to use simplifyingAdd() instead
of sigAdd(). This should throw out all the sigBinOp(kAdd)'s when all the
inputs are compile time constants, and this what we want/need.

No? I do not pretend to fully understand this nontrivial code.

I am resending my patch. The only change is that I moved the declaration
into aterm.hh and added the include into propagate.cpp.

Oleg.
---
 compiler/normalize/aterm.cpp     | 2 +-
 compiler/normalize/aterm.hh      | 2 ++
 compiler/propagate/propagate.cpp | 3 ++-
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/compiler/normalize/aterm.cpp b/compiler/normalize/aterm.cpp
index 3334f58c7..0642d30c1 100644
--- a/compiler/normalize/aterm.cpp
+++ b/compiler/normalize/aterm.cpp
@@ -47,7 +47,7 @@ aterm::aterm(Tree t)
 /**
  * Add two terms trying to simplify the result
  */
-static Tree simplifyingAdd(Tree t1, Tree t2)
+Tree simplifyingAdd(Tree t1, Tree t2)
 {
     faustassert(t1);
     faustassert(t2);
diff --git a/compiler/normalize/aterm.hh b/compiler/normalize/aterm.hh
index 9b32f5283..303c78920 100644
--- a/compiler/normalize/aterm.hh
+++ b/compiler/normalize/aterm.hh
@@ -66,4 +66,6 @@ inline std::ostream& operator<<(std::ostream& s, const aterm& 
a)
     return a.print(s);
 }
 
+Tree simplifyingAdd(Tree t1, Tree t2);
+
 #endif
diff --git a/compiler/propagate/propagate.cpp b/compiler/propagate/propagate.cpp
index 93abde239..af74f1882 100644
--- a/compiler/propagate/propagate.cpp
+++ b/compiler/propagate/propagate.cpp
@@ -31,6 +31,7 @@
 #include "prim2.hh"
 #include "simplify.hh"
 #include "xtended.hh"
+#include "aterm.hh"
 
 ////////////////////////////////////////////////////////////////////////
 /**
@@ -537,7 +538,7 @@ static siglist realPropagate(Tree slotenv, Tree path, Tree 
box, const siglist& l
                     Tree exp = outsigs[dst - 1];
                     if ((src > 0) & (src <= ins)) {
                         // we have a source
-                        outsigs[dst - 1] = sigAdd(exp, lsig[src - 1]);
+                        outsigs[dst - 1] = simplifyingAdd(exp, lsig[src - 1]);
                     }
                 }
             }
-- 
2.41.0




_______________________________________________
Faudiostream-devel mailing list
Faudiostream-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/faudiostream-devel

Reply via email to