Add not_int intrinsic for for-loop iteration support#107
Open
0xtaruhi wants to merge 2 commits intoJuliaGPU:mainfrom
Open
Add not_int intrinsic for for-loop iteration support#1070xtaruhi wants to merge 2 commits intoJuliaGPU:mainfrom
0xtaruhi wants to merge 2 commits intoJuliaGPU:mainfrom
Conversation
- Fix ShLIOp encoding to include overflow parameter - Refactor andi/ori/xori emit to use shared emit_binop! helper - Add codegen tests for bitwise ops (andi, ori, xori, shli, shri) - Add execution tests for bitwise ops to catch tileiras compilation issues
- Handle Core.Intrinsics.not_int via xori(x, allones) in julia.jl - Enables Julia's standard `for i in 1:n` loops in kernels - Add bitwise NOT (~) codegen test - Add execution tests: for-loop with literal, constant, and dynamic bounds
48bf507 to
6e038ef
Compare
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.
Summary
Julia desugars
for i in 1:nintoCore.Intrinsics.not_intto negate the loop-exit condition. Without handling this intrinsic, any kernel usingforloops hitsIRError("Unhandled Julia intrinsic: not_int").Implementation:
not_int(x)→xori(x, allones)where:xori(x, true)(logical negation)xori(x, -1)(bitwise complement, all bits set)Changes
src/compiler/intrinsics/julia.jlnot_intdispatch +emit_not_int!test/codegen/operations.jl~(bitwise NOT) codegen testtest/execution/basic.jl~execution test + 3for-loop execution testsTests
map(~, tile)bitwise NOT correctnessfor i in Int32(1):n_iters— literal boundfor i in Int32(1):Int32(n_iters)—ct.Constantboundfor j in Int32(1):len— dynamic bound from scalar indexingDepends on