1// An if-else statement at the end of a function, with a return as the last statement on all 2// paths, are not actually "early" returns. The inliner is able to recognize this pattern. 3 4uniform half4 colorGreen, colorRed; 5 6inline half branchy() { 7 if (colorGreen.g == 0) 8 return 0; 9 else if (colorRed.r == 0) 10 return 0; 11 else if (colorGreen == colorRed) 12 return 0; 13 else 14 return 1; 15} 16 17inline half branchyAndBlocky() { 18 if (colorGreen.g == 0) {{{ 19 return 0; 20 }}} else if (colorRed.r == 0) {{ 21 return 0; 22 }} else { if (colorGreen == colorRed) 23 return 0; 24 else {{ 25 return 1; 26 }}} 27} 28 29half4 main(float2 coords) { 30 return bool(branchy() * branchyAndBlocky()) ? colorGreen : colorRed; 31} 32