Just a guess, if it’s of the form
(x * b) + (x * b), that would trigger a muladd optimization, which would remove the first
* and the
+ in favor of a muladd. But here, there is only one
* so removing the “first” one also removes the “second.”
It depends how we are counting descendants of the
* UGen. If descendants are counted as number of target inputs, then the
* would have two descendants and the optimization should be skipped. If they’re counted as number of target UGens, then it would count one descendant, so it would look like a valid optimization (but it’s not).
I won’t quite put money on that but… check the count of descendants first.
A workaround would be to
commute redistribute the multiplication:
var x = SinOsc.ar(mul: 0.1);
x + x // KO
var y = SinOsc.ar;
(y + y) * 0.1 // OK
(So this is another argument in favor of writing
* instead of using
PS No access to github from my phone. I might check it myself later on the computer. Edit: Confirmed, this is exactly the problem.
descendants is a Set of unique UGens, not inputs. So it can’t detect the case of a UGen that feeds separately into two inputs of one other UGen.