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

missed optimization with return statement in function #1146

Open
1-Olivier opened this issue Apr 11, 2020 · 0 comments
Open

missed optimization with return statement in function #1146

1-Olivier opened this issue Apr 11, 2020 · 0 comments

Comments

@1-Olivier
Copy link

Consider this trivial shader:

vector foo(string a)
{
    if( a == "" )
        return 0;
    return 1;
}

surface simple(string s = "")
{
    P += foo(s);
}

running testshade --debug simple.oso yields, among a wall of text:

Optimized 8 ops to 6 (-25.0%)
Globals written: (1)  P

A simple change to the function:

vector foo(string a)
{
    if( a == "" )
        return 0;
    else
        return 1;
}

and the output is now:

Optimized 9 ops to 1 (-88.9%)
Globals written: (0)

I would expect the original function to allow the same optimization.

Versions

  • OSL branch/version: 1.10.9 (testshade output above) / 3d0a284 (where I originally found the issue in a larger network)
  • OS: linux
  • LLVM version: 9.0.1 / 6.0.0
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