Merge pull request #45067 from kitaisreal/jit-compilation-float-to-bool-conversion-fix

JIT compilation float to bool conversion fix
This commit is contained in:
Alexey Milovidov 2023-01-10 04:45:00 +03:00 committed by GitHub
commit c1ae35958d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 1 deletions

View File

@ -138,7 +138,7 @@ static inline llvm::Value * nativeBoolCast(llvm::IRBuilder<> & b, const DataType
if (value->getType()->isIntegerTy())
return b.CreateICmpNE(value, zero);
if (value->getType()->isFloatingPointTy())
return b.CreateFCmpONE(value, zero); /// QNaN is false
return b.CreateFCmpUNE(value, zero);
throw Exception(ErrorCodes::NOT_IMPLEMENTED, "Cannot cast non-number {} to bool", from_type->getName());
}

View File

@ -0,0 +1,4 @@
1
1
1
1

View File

@ -0,0 +1,9 @@
SET min_count_to_compile_expression = 0;
SELECT NOT NOT cos(MAX(pow(1523598955, 763027371))) FROM numbers(1) SETTINGS compile_expressions = 0;
SELECT NOT NOT cos(MAX(pow(1523598955, 763027371))) FROM numbers(1) SETTINGS compile_expressions = 1;
SELECT not(not(materialize(nan))) FROM numbers(1) SETTINGS compile_expressions = 0;
SELECT not(not(materialize(nan))) FROM numbers(1) SETTINGS compile_expressions = 1;