Make omission of impossible if-else branches work with constants

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