diff --git a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/bytecode/BytecodeCompiler.kt b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/bytecode/BytecodeCompiler.kt index 43a4b7f..cfbeb06 100644 --- a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/bytecode/BytecodeCompiler.kt +++ b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/bytecode/BytecodeCompiler.kt @@ -1683,12 +1683,12 @@ class BytecodeCompiler( val left = ensureObjSlot(a) val right = ensureObjSlot(b) val opcode = when { - isExactNonNullSlotClass(left.slot, ObjString.type) && - isExactNonNullSlotClass(right.slot, ObjString.type) -> stringOp - isExactNonNullSlotClass(left.slot, ObjInt.type) && - isExactNonNullSlotClass(right.slot, ObjInt.type) -> intOp - isExactNonNullSlotClass(left.slot, ObjReal.type) && - isExactNonNullSlotClass(right.slot, ObjReal.type) -> realOp + isExactNonNullSlotClassOrTemp(left.slot, ObjString.type) && + isExactNonNullSlotClassOrTemp(right.slot, ObjString.type) -> stringOp + isExactNonNullSlotClassOrTemp(left.slot, ObjInt.type) && + isExactNonNullSlotClassOrTemp(right.slot, ObjInt.type) -> intOp + isExactNonNullSlotClassOrTemp(left.slot, ObjReal.type) && + isExactNonNullSlotClassOrTemp(right.slot, ObjReal.type) -> realOp else -> objOp } builder.emit(opcode, left.slot, right.slot, out) diff --git a/notes/fast_ops_optimizations_plan.md b/notes/fast_ops_optimizations_plan.md index b43af54..a040538 100644 --- a/notes/fast_ops_optimizations_plan.md +++ b/notes/fast_ops_optimizations_plan.md @@ -4,8 +4,9 @@ Baseline - See `notes/nested_range_baseline.md` Candidates (not started) -1) Primitive comparisons - - Emit fast CMP variants for known ObjString/ObjInt/ObjReal/ObjBool across all comparison operators. +1) Primitive comparisons (done) + - Emit fast CMP variants for known ObjString/ObjInt/ObjReal using temp/stable slots. + - MixedCompareBenchmarkTest: 374 ms -> 347 ms. 2) Mixed numeric ops - Ensure INT+REAL arithmetic uses INT_TO_REAL + REAL op with no extra moves/boxing. 3) Boolean conversion