Skip to content

Commit 71c5c9e

Browse files
committed
LLVMCodeBuilder: Optimize number and string const comparison
1 parent bce615b commit 71c5c9e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/dev/engine/internal/llvm/llvmcodebuilder.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2347,6 +2347,13 @@ llvm::Value *LLVMCodeBuilder::createComparison(LLVMRegister *arg1, LLVMRegister
23472347
optNumberBool = 1; // operand 1 was bool
23482348
}
23492349

2350+
// Optimize number and string constant comparison
2351+
if (type1 == Compiler::StaticType::Number && type2 == Compiler::StaticType::String && arg2->isConst() && !arg2->constValue().isValidNumber())
2352+
return m_builder.getInt1(false);
2353+
2354+
if (type1 == Compiler::StaticType::String && type2 == Compiler::StaticType::Number && arg1->isConst() && !arg1->constValue().isValidNumber())
2355+
return m_builder.getInt1(false);
2356+
23502357
if (type1 != type2 || type1 == Compiler::StaticType::Unknown || type2 == Compiler::StaticType::Unknown) {
23512358
// If the types are different or at least one of them
23522359
// is unknown, we must use value functions

0 commit comments

Comments
 (0)