|
543 | 543 | # A `call` instruction targeting an LLVM intrinsic (`@llvm.ctpop`, `@llvm.abs`, …) is a single native instruction, not a runtime dispatch. Only flag calls into Julia runtime functions (`@j_*`, `@julia_*`, `@ijl_*`, `@jl_*`). |
544 | 544 | runtime_calls(ops) = count(l -> occursin("call ", l) && !occursin("@llvm.", l), ops) |
545 | 545 |
|
| 546 | +# Unnamed SSA values (`%16`, `%11`, …) are numbered sequentially across the whole function, so the same operation sequence picks up different numbers depending on how much unrelated code precedes it (coverage counters, surrounding context). Renumber each distinct `%<n>` by order of first appearance so equality checks compare structure and data flow rather than absolute ids. Named values like `%"x::Int3"` have no digit right after `%` and are left untouched. |
| 547 | +function normalize_ssa(ops) |
| 548 | + mapping = Dict{String, Int}() |
| 549 | + map(ops) do l |
| 550 | + replace(l, r"%\d+" => m -> "%" * string(get!(mapping, m, length(mapping)))) |
| 551 | + end |
| 552 | +end |
| 553 | + |
546 | 554 | @testset "performance invariants" begin |
547 | 555 | using InteractiveUtils |
548 | 556 | @emulate UInt3 Int3 UInt20 |
@@ -584,10 +592,10 @@ runtime_calls(ops) = count(l -> occursin("call ", l) && !occursin("@llvm.", l), |
584 | 592 | VERSION >= v"1.11" && @test length(ops) == exact_ops |
585 | 593 | end |
586 | 594 |
|
587 | | - @test llvm_ops(le_uint_2, Tuple{UInt}) == llvm_ops(le_int_2, Tuple{UInt}) |
588 | | - @test llvm_ops(le_int3_2, Tuple{Int3}) == llvm_ops(le_int3_int_2, Tuple{Int3}) |
589 | | - @test llvm_ops(le_uint3_2, Tuple{UInt3}) == llvm_ops(le_uint3_int_2, Tuple{UInt3}) |
590 | | - @test llvm_ops(le_uint_typemax_int, Tuple{UInt}) == llvm_ops(le_int_typemax_int, Tuple{UInt}) |
| 595 | + @test normalize_ssa(llvm_ops(le_uint_2, Tuple{UInt})) == normalize_ssa(llvm_ops(le_int_2, Tuple{UInt})) |
| 596 | + @test normalize_ssa(llvm_ops(le_int3_2, Tuple{Int3})) == normalize_ssa(llvm_ops(le_int3_int_2, Tuple{Int3})) |
| 597 | + @test normalize_ssa(llvm_ops(le_uint3_2, Tuple{UInt3})) == normalize_ssa(llvm_ops(le_uint3_int_2, Tuple{UInt3})) |
| 598 | + @test normalize_ssa(llvm_ops(le_uint_typemax_int, Tuple{UInt})) == normalize_ssa(llvm_ops(le_int_typemax_int, Tuple{UInt})) |
591 | 599 | end |
592 | 600 |
|
593 | 601 |
|
|
0 commit comments