Skip to content

Srol pass#11

Open
adienes wants to merge 7 commits intomasterfrom
srol_pass
Open

Srol pass#11
adienes wants to merge 7 commits intomasterfrom
srol_pass

Conversation

@adienes
Copy link
Copy Markdown
Owner

@adienes adienes commented Jan 29, 2026

julia> mutable struct Foo{N}
           data::NTuple{N, Int}
       end

julia> get1(foo, i) = @inbounds return foo.data[i]
get1 (generic function with 1 method)

julia> get2(foo, i) = unsafe_load(convert(Ptr{Int}, pointer_from_objref(foo)), i)
get2 (generic function with 1 method)

julia> const foo = Foo(ntuple(x -> x, 10_000));

julia> using BenchmarkTools

julia> @btime sum(_ -> get1(foo, rand(1:10_000))^rand(), 100)
  954.100 ns (0 allocations: 0 bytes) # 21.314 ns (0 allocations: 0 bytes) after PR
915.1602897108014

julia> @btime sum(_ -> get2(foo, rand(1:10_000))^rand(), 100)
  21.314 ns (0 allocations: 0 bytes)
5979.469497928203

adienes and others added 2 commits January 29, 2026 11:29
- Fix IR_FLAG_NOUB to only be set when the compiler proved bounds
  safety (via IR_FLAG_NOTHROW), not when @inbounds was used. Using
  @inbounds is a user assertion that could be wrong, so the operation
  may still have UB.
- Simplify homogeneous tuple check using `all(==(...), ...)`
- Improve SSA renaming to handle Argument values
- Add test for IR_FLAG_NOUB distinction
- Add test for heterogeneous tuples (should not be optimized)
- Add test for multiple SROL candidates in same function

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant