From fe49ee6448fc51651996d5c6302b6bc86cb65435 Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Mon, 10 Nov 2008 20:55:24 +0100 Subject: [PATCH] Special case DtoCastInt for bool. --- gen/llvmhelpers.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gen/llvmhelpers.cpp b/gen/llvmhelpers.cpp index 9c68808b..50e16243 100644 --- a/gen/llvmhelpers.cpp +++ b/gen/llvmhelpers.cpp @@ -570,7 +570,7 @@ DValue* DtoCastInt(Loc& loc, DValue* val, Type* _to) } if (to->isintegral()) { - if (fromsz < tosz) { + if (fromsz < tosz || from->ty == Tbool) { if (Logger::enabled()) Logger::cout() << "cast to: " << *tolltype << '\n'; if (from->isunsigned() || from->ty == Tbool) { @@ -579,7 +579,7 @@ DValue* DtoCastInt(Loc& loc, DValue* val, Type* _to) rval = new llvm::SExtInst(rval, tolltype, "tmp", gIR->scopebb()); } } - else if (fromsz > tosz) { + else if (fromsz > tosz || to->ty == Tbool) { rval = new llvm::TruncInst(rval, tolltype, "tmp", gIR->scopebb()); } else {