Dispatch numeric comparison operators to Native types for direct codegen#12855
Merged
Simn merged 3 commits intohaxe-numericfrom Mar 20, 2026
Merged
Dispatch numeric comparison operators to Native types for direct codegen#12855Simn merged 3 commits intohaxe-numericfrom
Simn merged 3 commits intohaxe-numericfrom
Conversation
…odegen
Add lt/lte/gt/gte (signed) and ult/ulte/ugt/ugte (unsigned) comparison
functions to Int32Native, Int32Direct, Int64Native, and all target-specific
overrides (JVM, HL, C++, eval).
Update Int32/Int64/UInt32/UInt64 abstract operators to call these native
functions directly instead of going through compare()/ucompare().
On targets with native support (JVM, HL), signed comparisons now generate
direct native comparison operators instead of the multi-branch
compare-return-{-1,0,1}-then-check pattern.
HL bytecode improvement for Int32 < Int: 19 → 11 instructions
HL bytecode improvement for Int64 < Int: 20 → 12 instructions
Updated hlcode test expectations accordingly.
Co-authored-by: Simn <634365+Simn@users.noreply.github.com>
Agent-Logs-Url: https://github.com/HaxeFoundation/haxe/sessions/00ae78d7-e1c3-49a6-8216-da0541560084
Co-authored-by: Simn <634365+Simn@users.noreply.github.com> Agent-Logs-Url: https://github.com/HaxeFoundation/haxe/sessions/00ae78d7-e1c3-49a6-8216-da0541560084
Copilot
AI
changed the title
[WIP] Unify numeric types API across all targets
Dispatch numeric comparison operators to Native types for direct codegen
Mar 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Comparison operators on
Int32/Int64/UInt32/UInt64were going throughcompare()→ return{-1,0,1}→ check against0, producing unnecessarily branchy code on targets with native support. This change dispatches comparisons directly toInt32Native/Int64Native, enabling native comparison operators on JVM and HL.Changes
Int32Native/Int64Nativeimplementations:lt/lte/gt/gte(signed) andult/ulte/ugt/ugte(unsigned), across default emulated,Int32Direct, JVM, HL, C++, and eval overrides(a : jvm.Int64) < (b : jvm.Int64)instead of the three-way compare patternInt32.lt→Int32Native.lt,UInt64.lt→Int64Native.ult, etc.ucompareinternally (sign-handling logic required)HL bytecode impact
compare()/ucompare()functions remain available for the public API; only the@:opdispatch path changed.⚡ Quickly spin up Copilot coding agent tasks from anywhere on your macOS or Windows machine with Raycast.