How does nvcc deal with constants?

const int a = 10;
if(a == 10) {
//Do X
} else {
//Do Y

I would have thought that in this case, the code would be rewritten to:
const int a = 10;
//Do X

Because we know at compile-time which if branch will execute, every time.
However, this is not the case during debugging. Is this not at all as trivial as I thought for the compiler? Or does it actually happen, but not when debugging information is written?

The dead code optimizer in nvcc is very aggressive. I would be very surprised if it didn’t optimize away Do Y. To check, simply compile your kernel to ptx assembly and see if code for Do Y is output or not.

Compiling in debug mode removes -O3. So I would guess that the dead code optimizer is simply turned off…