Add a function to check whether a ValueRef is a constant
Make omission of impossible if-else branches work with constants

Until now, we only optimized away impossible branches when there is a
literal true/false 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
Generate branchless code when "if" can be evaluated at compile time

We already avoid the conditional branch, but still have an
unconditional branch in the generated code. Remove it.
auto merge of #8041 : dotdash/rust/const_if_else, r=huonw