Please sign in to comment.
Fix `exit` not being recognized as basic block end (#1051)
Stale assignment elision was broken in the presence of `exit`. In general a = 10; ... stuff not involving `a`... a = 20; sees two assignments within the same basic block, and because `a` is not used between the two assignments, the first one can be eliminated. But this optimization ("stale assignment elision") was wrong for this modified code: a = 10; return; // note: `return` in the main shader body is the same as `exit()` a = 20; because the `return` changes things -- the second assignment won't be executed, and therefore should not retroactively eliminate the earlier assignment. The correct final value of a is indeed 10. The problem boiled down to a bug in OSOProcessorBase::find_basic_blocks, where the `exit` op was simply not recognized as terminating its basic block (since it is a jump).
- Loading branch information...
Showing with 23 additions and 4 deletions.
BIN +225 Bytes testsuite/bug-return/ref/out.tif
Binary file not shown.
|@@ -0,0 +1,3 @@|
|Compiled test.osl -> test.oso|
|Output Cout to out.tif|
|@@ -0,0 +1,4 @@|
|command += testshade("-g 1 1 --center -od uint8 -o Cout out.tif test")|
|outputs = [ "out.txt", "out.tif" ]|
|@@ -0,0 +1,11 @@|
|// Regression for a early return bug which nops the first assignment in favor of an unreachable one|
|test (output color Cout = 0)|
|Cout = color (0, 1, 0);|
|Cout = color(1, 0, 0);|