How good is NVCC as at optimizations?
How well does NVCC optimize device code? Does it do any sort of optimizations like constant folding and common subexpression elimination?

E.g, will it reduce the following:

    float a = 1 / sqrtf(2 * M_PI);
    float b = c / sqrtf(2 * M_PI);

to this:

    float sqrt_2pi = sqrtf(2 * M_PI); // Compile time constant
    float a = 1 / sqrt_2pi;
    float b = c / sqrt_2pi;

What about more clever optimizations, involving knowing semantics of math functions:

    float a = 1 / sqrtf(c * M_PI);
    float b = c / sqrtf(M_PI);

to this:

    float sqrt_pi = sqrtf(M_PI); // Compile time constant
    float a = 1 / (sqrt_pi * sqrtf(c));
    float b = c / sqrt_pi;
How good is NVCC as at optimizations?
===

How well does NVCC optimize device code? Does it do any sort of optimizations like constant folding and common subexpression elimination?

E.g, will it reduce the following:

    float a = 1 / sqrtf(2 * M_PI);
    float b = c / sqrtf(2 * M_PI);

to this:

    float sqrt_2pi = sqrtf(2 * M_PI); // Compile time constant
    float a = 1 / sqrt_2pi;
    float b = c / sqrt_2pi;

What about more clever optimizations, involving knowing semantics of math functions:

    float a = 1 / sqrtf(c * M_PI);
    float b = c / sqrtf(M_PI);

to this:

    float sqrt_pi = sqrtf(M_PI); // Compile time constant
    float a = 1 / (sqrt_pi * sqrtf(c));
    float b = c / sqrt_pi;