Use folded constants to omit impossible if-else branches

Until now, we only optimized away impossible branches when there is a
literal if/else in the code. But since the LLVM IR builder already does
constant folding for us, we can trivially expand that to work with
constants as well.

Refs #7834