aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index 8dbf78c270..d6ec50ae16 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -493,6 +493,11 @@ void SelectionDAGLowering::visitCast(User &I) {
if (N.getValueType() == DestTy) {
setValue(&I, N); // noop cast.
+ } else if (DestTy == MVT::i1) {
+ // Cast to bool is a comparison against zero, not truncation to zero.
+ SDOperand Zero = isInteger(SrcTy) ? DAG.getConstant(0, N.getValueType()) :
+ DAG.getConstantFP(0.0, N.getValueType());
+ setValue(&I, DAG.getSetCC(ISD::SETNE, MVT::i1, N, Zero));
} else if (isInteger(SrcTy)) {
if (isInteger(DestTy)) { // Int -> Int cast
if (DestTy < SrcTy) // Truncating cast?