I use python's sympy model to solve a lot of symbolic algebra problems, and when looking to export solutions to c++ for higher performance applications, I've noticed patterns like this appearing a lot in my code:
vec4 input_color = vec4(1.0, 0.2, 0.8, 1.0);
vec4 c31 = srgb_to_cie31(input_color);
//c31[2] *= 2.0;
vec4 output_color = cie31_to_srgb(c31);
If line 3 is commented out, input_color passes through a function, and immediately through its inverse. For some "trapdoor" functions, one of these can be expensive or approximate. Is there any way I can hint msvc / gcc to recognize this, and compile away all of these steps?