This code was incorrectly folding:
IRBuilder.CreateICmp(int_ty X, bitcast (float_ty Y) to int_ty)
to:
IRBuilder.CreateICmp(bitcast (int_ty X) to float_ty, float_ty Y)
which is malformed IR due to the mismatch between the integer predicate and the FP operands. In my case, this triggered a crash in an optimization pass.