- if (Instruction *I = commonCastTransforms(CI))
- return I;
-
- // FIXME. We currently implement cast-to-bool as a setne %X, 0. This is
- // because codegen cannot accurately perform a truncate to bool operation.
- // Something goes wrong in promotion to a larger type. When CodeGen can
- // handle a proper truncation to bool, this should be removed.
- Value *Src = CI.getOperand(0);
- const Type *SrcTy = Src->getType();
- const Type *DestTy = CI.getType();
- if (DestTy == Type::BoolTy)
- return BinaryOperator::createSetNE(Src, Constant::getNullValue(SrcTy));
- return 0;