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 · 5 comments
Open

unnecessary slow variable is created #1094

crop2000 opened this issue Dec 14, 2024 · 5 comments

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.

@Vineet1101
Copy link

Hey @crop2000 i would like to fix this issue as this seems simple so it will be a good starting point for me

@crop2000
Copy link
Contributor Author

Hey @Vineet1101 it seems that @sletz is not interested in a fix right now.

@sletz
Copy link
Member

sletz commented Jan 19, 2025

Sharing management has a lot of subtle consequences in different parts of the compilation process. We simply cannot merge this with a full understand of everything, and a lot of testing. This PR will stay as a starting point of what has to be done for now.

@crop2000
Copy link
Contributor Author

@sletz What kind of testing would you propose?

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

3 participants