Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unnecessary slow variable is created #1094

Open
crop2000 opened this issue Dec 14, 2024 · 1 comment
Open

unnecessary slow variable is created #1094

crop2000 opened this issue Dec 14, 2024 · 1 comment

Comments

@crop2000
Copy link
Contributor

I realized that the following faust dsp creates a unecessary slow variable fSlow0.

import("stdfaust.lib");
volumeM = vslider("volume", 0, -70, +4, 0.1) : ba.db2linear;
process(a) = attach(volumeM:vbargraph("level",0,1));
      virtual void compute(int count, FAUSTFLOAT** RESTRICT inputs, FAUSTFLOAT** RESTRICT outputs) {
		FAUSTFLOAT* input0 = inputs[0];
		FAUSTFLOAT* input1 = inputs[1];
		FAUSTFLOAT* output0 = outputs[0];
		fVbargraph0 = FAUSTFLOAT(std::pow(1e+01f, 0.05f * float(fVslider0)));
		float fSlow0 = fVbargraph0;
		for (int i0 = 0; i0 < count; i0 = i0 + 1) {
			output0[i0] = FAUSTFLOAT(float(input1[i0]));
		}
	}

this becomes relevant if -ec is used because in this case it cannot be simply optimized away.

@crop2000
Copy link
Contributor Author

this issue can be solved by the following fix:
simplify the code by using occurence:
443fbeb
and don't expand variability if it would happen inside attach in the second arm:
b57237a
the linked commits are part of a PR that introduces also other improvements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant