Skip to content

Conversation

@gbaraldi
Copy link
Member

@gbaraldi gbaraldi commented Jan 26, 2026

Summary

  • Add small tags for IR node types commonly used in _useref_getindex: Argument, GotoIfNot, ReturnNode, EnterNode, PiNode, PhiNode, PhiCNode, UpsilonNode, GlobalRef, GotoNode, and QuoteNode
  • This enables the compiler to generate efficient switch statements based on the type tags instead of pointer comparisons
  • Split _useref_getindex into separate op==1 and op>1 paths to avoid redundant comparisons

Test plan

  • Julia builds successfully
  • Verified LLVM IR shows efficient switch statements on smalltags

🤖 Generated with Claude Code

Add small tags for IR node types commonly used in `_useref_getindex`:
Argument, GotoIfNot, ReturnNode, EnterNode, PiNode, PhiNode, PhiCNode,
UpsilonNode, GlobalRef, GotoNode, and QuoteNode. This enables the
compiler to generate efficient switch statements based on the type tags
instead of pointer comparisons.

Also split `_useref_getindex` into separate `op==1` and `op>1` paths.
Most IR node types only have a single operand, so the `op==1` path can
return directly without redundant `op == 1 || return OOB_TOKEN` checks.
The `op>1` path only handles types that can have multiple operands
(Expr, PhiNode, PhiCNode).

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@gbaraldi gbaraldi force-pushed the gbaraldi/smalltags-ir-types branch from f629ef0 to 6d9d7cd Compare January 26, 2026 19:16
end
end

@noinline function _useref_getindex_op1(@nospecialize(stmt))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could it potentially be worth to inline this if most nodes have op==1?

Copy link
Member Author

@gbaraldi gbaraldi Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a pretty bulky function so it's a bit unclear if there are too many wins. And we don't want a bunch of copies of it around using icache space

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

latency Latency

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants