How to dump optimized IR?

I have a simple python function with an unused intermediate variable. How can I dump optimized IR? which shows the unused variable being removed. NUMBA_DUMP_IR=1 only shows non-optimized IR.

Additionally, can I turn off all the optimization passes and enable them individually? Are there certain optimizations that cannot be turned off with stock numba?

@njit('float32(float32, float32)')
def adder(a, b):
    inter = 5.0
    total = 0.0
    total = a+b
    return total

NUMBA_TRACE=1 NUMBA_DUMP_IR=1 python extract.py

== Pipeline: nopython for __main__.adder
== -- analyzing bytecode
== -- fix up args
== -- processing IR
---------------------------------IR DUMP: adder---------------------------------
label 0:
    a = arg(0, name=a)                       ['a']
    b = arg(1, name=b)                       ['b']
    inter = const(float, 5.0)                ['inter']
    total = const(float, 0.0)                ['total']
    total.1 = a + b                          ['a', 'b', 'total.1']
    $24return_value.6 = cast(value=total.1)  ['$24return_value.6', 'total.1']
    return $24return_value.6                 ['$24return_value.6']

== -- Handle with contexts
== -- inline calls to locally defined closures
== -- rewrite semantic constants
== -- dead branch pruning
== -- nopython rewrites
== -- rewrite dynamic raises
== -- convert make_function into JIT functions
== -- inline inlinable functions
== -- dead branch pruning
== -- find literally calls
== -- handles literal_unroll
== -- ssa
== -- Literal propagation
== -- nopython frontend
== -- remove phis nodes
== -- inline overloaded functions
== -- nopython rewrites
== -- ensure features that are in use are in a valid form
== -- ensure IR is legal prior to lowering
== -- annotate types
== -- native lowering
== -- nopython mode backend
== -- dump parfor diagnostics

You can set NUMBA_DUMP_OPTIMIZED=1 - see Environment variables — Numba 0+untagged.871.g53e976f.dirty documentation

I’m aware of NUMBA_DUMP_OPTIMIZED, but that outputs LLVM IR, which is not what I’m looking for. I’m seeking the same IR format dump, which I believe is Numba’s IR, but the optimized version of it. The issue with LLVM IR is that it contains a lot of noise with metadata.

Whoops, sorry - I misunderstood / misread the question. Perhaps setting the NUMBA_DEBUG_PRINT_AFTER environment variable is helpful - e.g. NUMBA_DEBUG_PRINT_AFTER=all.

For a simple function, this gives me something like:

(Example of dump after all passes, long output)
$ NUMBA_DEBUG_PRINT_AFTER=all python -c "from numba import njit; njit('int32(int32, int32)')(lambda x, y: x + y)"
---------------------------------__main__.<lambda>: nopython: AFTER translate_bytecode----------------------------------
label 0:
    x = arg(0, name=x)                       ['x']
    y = arg(1, name=y)                       ['y']
    $binop_add8.2 = x + y                    ['$binop_add8.2', 'x', 'y']
    $12return_value.3 = cast(value=$binop_add8.2) ['$12return_value.3', '$binop_add8.2']
    return $12return_value.3                 ['$12return_value.3']

-------------------------------------__main__.<lambda>: nopython: AFTER fixup_args--------------------------------------
label 0:
    x = arg(0, name=x)                       ['x']
    y = arg(1, name=y)                       ['y']
    $binop_add8.2 = x + y                    ['$binop_add8.2', 'x', 'y']
    $12return_value.3 = cast(value=$binop_add8.2) ['$12return_value.3', '$binop_add8.2']
    return $12return_value.3                 ['$12return_value.3']

------------------------------------__main__.<lambda>: nopython: AFTER ir_processing------------------------------------
label 0:
    x = arg(0, name=x)                       ['x']
    y = arg(1, name=y)                       ['y']
    $binop_add8.2 = x + y                    ['$binop_add8.2', 'x', 'y']
    $12return_value.3 = cast(value=$binop_add8.2) ['$12return_value.3', '$binop_add8.2']
    return $12return_value.3                 ['$12return_value.3']

------------------------------------__main__.<lambda>: nopython: AFTER with_lifting-------------------------------------
label 0:
    x = arg(0, name=x)                       ['x']
    y = arg(1, name=y)                       ['y']
    $binop_add8.2 = x + y                    ['$binop_add8.2', 'x', 'y']
    $12return_value.3 = cast(value=$binop_add8.2) ['$12return_value.3', '$binop_add8.2']
    return $12return_value.3                 ['$12return_value.3']

--------------------------------__main__.<lambda>: nopython: AFTER inline_closure_likes---------------------------------
label 0:
    x = arg(0, name=x)                       ['x']
    y = arg(1, name=y)                       ['y']
    $binop_add8.2 = x + y                    ['$binop_add8.2', 'x', 'y']
    $12return_value.3 = cast(value=$binop_add8.2) ['$12return_value.3', '$binop_add8.2']
    return $12return_value.3                 ['$12return_value.3']

-----------------------------__main__.<lambda>: nopython: AFTER rewrite_semantic_constants------------------------------
label 0:
    x = arg(0, name=x)                       ['x']
    y = arg(1, name=y)                       ['y']
    $binop_add8.2 = x + y                    ['$binop_add8.2', 'x', 'y']
    $12return_value.3 = cast(value=$binop_add8.2) ['$12return_value.3', '$binop_add8.2']
    return $12return_value.3                 ['$12return_value.3']

----------------------------------__main__.<lambda>: nopython: AFTER dead_branch_prune----------------------------------
label 0:
    x = arg(0, name=x)                       ['x']
    y = arg(1, name=y)                       ['y']
    $binop_add8.2 = x + y                    ['$binop_add8.2', 'x', 'y']
    $12return_value.3 = cast(value=$binop_add8.2) ['$12return_value.3', '$binop_add8.2']
    return $12return_value.3                 ['$12return_value.3']

----------------------------------__main__.<lambda>: nopython: AFTER generic_rewrites-----------------------------------
label 0:
    x = arg(0, name=x)                       ['x']
    y = arg(1, name=y)                       ['y']
    $binop_add8.2 = x + y                    ['$binop_add8.2', 'x', 'y']
    $12return_value.3 = cast(value=$binop_add8.2) ['$12return_value.3', '$binop_add8.2']
    return $12return_value.3                 ['$12return_value.3']

-------------------------------__main__.<lambda>: nopython: AFTER Rewrite dynamic raises--------------------------------
label 0:
    x = arg(0, name=x)                       ['x']
    y = arg(1, name=y)                       ['y']
    $binop_add8.2 = x + y                    ['$binop_add8.2', 'x', 'y']
    $12return_value.3 = cast(value=$binop_add8.2) ['$12return_value.3', '$binop_add8.2']
    return $12return_value.3                 ['$12return_value.3']

------------------------__main__.<lambda>: nopython: AFTER make_function_op_code_to_jit_function------------------------
label 0:
    x = arg(0, name=x)                       ['x']
    y = arg(1, name=y)                       ['y']
    $binop_add8.2 = x + y                    ['$binop_add8.2', 'x', 'y']
    $12return_value.3 = cast(value=$binop_add8.2) ['$12return_value.3', '$binop_add8.2']
    return $12return_value.3                 ['$12return_value.3']

----------------------------------__main__.<lambda>: nopython: AFTER inline_inlinables----------------------------------
label 0:
    x = arg(0, name=x)                       ['x']
    y = arg(1, name=y)                       ['y']
    $binop_add8.2 = x + y                    ['$binop_add8.2', 'x', 'y']
    $12return_value.3 = cast(value=$binop_add8.2) ['$12return_value.3', '$binop_add8.2']
    return $12return_value.3                 ['$12return_value.3']

----------------------------------__main__.<lambda>: nopython: AFTER dead_branch_prune----------------------------------
label 0:
    x = arg(0, name=x)                       ['x']
    y = arg(1, name=y)                       ['y']
    $binop_add8.2 = x + y                    ['$binop_add8.2', 'x', 'y']
    $12return_value.3 = cast(value=$binop_add8.2) ['$12return_value.3', '$binop_add8.2']
    return $12return_value.3                 ['$12return_value.3']

-----------------------------------__main__.<lambda>: nopython: AFTER find_literally------------------------------------
label 0:
    x = arg(0, name=x)                       ['x']
    y = arg(1, name=y)                       ['y']
    $binop_add8.2 = x + y                    ['$binop_add8.2', 'x', 'y']
    $12return_value.3 = cast(value=$binop_add8.2) ['$12return_value.3', '$binop_add8.2']
    return $12return_value.3                 ['$12return_value.3']

-----------------------------------__main__.<lambda>: nopython: AFTER literal_unroll------------------------------------
label 0:
    x = arg(0, name=x)                       ['x']
    y = arg(1, name=y)                       ['y']
    $binop_add8.2 = x + y                    ['$binop_add8.2', 'x', 'y']
    $12return_value.3 = cast(value=$binop_add8.2) ['$12return_value.3', '$binop_add8.2']
    return $12return_value.3                 ['$12return_value.3']

-----------------------------------__main__.<lambda>: nopython: AFTER reconstruct_ssa-----------------------------------
label 0:
    x = arg(0, name=x)                       ['x']
    y = arg(1, name=y)                       ['y']
    $binop_add8.2 = x + y                    ['$binop_add8.2', 'x', 'y']
    $12return_value.3 = cast(value=$binop_add8.2) ['$12return_value.3', '$binop_add8.2']
    return $12return_value.3                 ['$12return_value.3']

----------------------------------__main__.<lambda>: nopython: AFTER dead_branch_prune----------------------------------
label 0:
    x = arg(0, name=x)                       ['x']
    y = arg(1, name=y)                       ['y']
    $binop_add8.2 = x + y                    ['$binop_add8.2', 'x', 'y']
    $12return_value.3 = cast(value=$binop_add8.2) ['$12return_value.3', '$binop_add8.2']
    return $12return_value.3                 ['$12return_value.3']

---------------------------------__main__.<lambda>: nopython: AFTER LiteralPropagation----------------------------------
label 0:
    x = arg(0, name=x)                       ['x']
    y = arg(1, name=y)                       ['y']
    $binop_add8.2 = x + y                    ['$binop_add8.2', 'x', 'y']
    $12return_value.3 = cast(value=$binop_add8.2) ['$12return_value.3', '$binop_add8.2']
    return $12return_value.3                 ['$12return_value.3']

-------------------------------__main__.<lambda>: nopython: AFTER nopython_type_inference-------------------------------
label 0:
    x = arg(0, name=x)                       ['x']
    y = arg(1, name=y)                       ['y']
    $binop_add8.2 = x + y                    ['$binop_add8.2', 'x', 'y']
    $12return_value.3 = cast(value=$binop_add8.2) ['$12return_value.3', '$binop_add8.2']
    return $12return_value.3                 ['$12return_value.3']

-------------------------------------__main__.<lambda>: nopython: AFTER strip_phis--------------------------------------
label 0:
    x = arg(0, name=x)                       ['x']
    y = arg(1, name=y)                       ['y']
    $binop_add8.2 = x + y                    ['$binop_add8.2', 'x', 'y']
    $12return_value.3 = cast(value=$binop_add8.2) ['$12return_value.3', '$binop_add8.2']
    return $12return_value.3                 ['$12return_value.3']

----------------------------------__main__.<lambda>: nopython: AFTER inline_overloads-----------------------------------
label 0:
    x = arg(0, name=x)                       ['x']
    y = arg(1, name=y)                       ['y']
    $binop_add8.2 = x + y                    ['$binop_add8.2', 'x', 'y']
    $12return_value.3 = cast(value=$binop_add8.2) ['$12return_value.3', '$binop_add8.2']
    return $12return_value.3                 ['$12return_value.3']

----------------------------------__main__.<lambda>: nopython: AFTER nopython_rewrites----------------------------------
label 0:
    x = arg(0, name=x)                       ['x']
    y = arg(1, name=y)                       ['y']
    $binop_add8.2 = x + y                    ['$binop_add8.2', 'x', 'y']
    $12return_value.3 = cast(value=$binop_add8.2) ['$12return_value.3', '$binop_add8.2']
    return $12return_value.3                 ['$12return_value.3']

------------------------__main__.<lambda>: nopython: AFTER nopython_supported_feature_validation------------------------
label 0:
    x = arg(0, name=x)                       ['x']
    y = arg(1, name=y)                       ['y']
    $binop_add8.2 = x + y                    ['$binop_add8.2', 'x', 'y']
    $12return_value.3 = cast(value=$binop_add8.2) ['$12return_value.3', '$binop_add8.2']
    return $12return_value.3                 ['$12return_value.3']

-----------------------------------__main__.<lambda>: nopython: AFTER ir_legalization-----------------------------------
label 0:
    x = arg(0, name=x)                       ['x']
    y = arg(1, name=y)                       ['y']
    $binop_add8.2 = x + y                    ['$binop_add8.2', 'x', 'y']
    del y                                    []
    del x                                    []
    $12return_value.3 = cast(value=$binop_add8.2) ['$12return_value.3', '$binop_add8.2']
    del $binop_add8.2                        []
    return $12return_value.3                 ['$12return_value.3']

-----------------------------------__main__.<lambda>: nopython: AFTER annotate_types------------------------------------
label 0:
    x = arg(0, name=x)                       ['x']
    y = arg(1, name=y)                       ['y']
    $binop_add8.2 = x + y                    ['$binop_add8.2', 'x', 'y']
    del y                                    []
    del x                                    []
    $12return_value.3 = cast(value=$binop_add8.2) ['$12return_value.3', '$binop_add8.2']
    del $binop_add8.2                        []
    return $12return_value.3                 ['$12return_value.3']

-----------------------------------__main__.<lambda>: nopython: AFTER native_lowering-----------------------------------
label 0:
    x = arg(0, name=x)                       ['x']
    y = arg(1, name=y)                       ['y']
    $binop_add8.2 = x + y                    ['$binop_add8.2', 'x', 'y']
    del y                                    []
    del x                                    []
    $12return_value.3 = cast(value=$binop_add8.2) ['$12return_value.3', '$binop_add8.2']
    del $binop_add8.2                        []
    return $12return_value.3                 ['$12return_value.3']

----------------------------------__main__.<lambda>: nopython: AFTER nopython_backend-----------------------------------
label 0:
    x = arg(0, name=x)                       ['x']
    y = arg(1, name=y)                       ['y']
    $binop_add8.2 = x + y                    ['$binop_add8.2', 'x', 'y']
    del y                                    []
    del x                                    []
    $12return_value.3 = cast(value=$binop_add8.2) ['$12return_value.3', '$binop_add8.2']
    del $binop_add8.2                        []
    return $12return_value.3                 ['$12return_value.3']

-------------------------------__main__.<lambda>: nopython: AFTER dump_parfor_diagnostics-------------------------------
label 0:
    x = arg(0, name=x)                       ['x']
    y = arg(1, name=y)                       ['y']
    $binop_add8.2 = x + y                    ['$binop_add8.2', 'x', 'y']
    del y                                    []
    del x                                    []
    $12return_value.3 = cast(value=$binop_add8.2) ['$12return_value.3', '$binop_add8.2']
    del $binop_add8.2                        []
    return $12return_value.3                 ['$12return_value.3']

I still don’t see an IR that removes the unused constant. I’m expecting “inter” variable entry to be removed from the IR after optimization. Does numba even output this kind of information? more importantly, does numba even optimize for this?

What would be the best way to illustrate before and after code transformation? Would translating the IR to some kind of a directed graph show this? for ex. for unused variable it would show a node with no incoming edges?

-----------------------------------__main__.adder: nopython: AFTER translate_bytecode-----------------------------------
label 0:
    a = arg(0, name=a)                       ['a']
    b = arg(1, name=b)                       ['b']
    inter = const(float, 5.0)                ['inter']
    total = const(float, 0.0)                ['total']
    total.1 = a + b                          ['a', 'b', 'total.1']
    $24return_value.6 = cast(value=total.1)  ['$24return_value.6', 'total.1']
    return $24return_value.6                 ['$24return_value.6']

---------------------------------------__main__.adder: nopython: AFTER fixup_args---------------------------------------
label 0:
    a = arg(0, name=a)                       ['a']
    b = arg(1, name=b)                       ['b']
    inter = const(float, 5.0)                ['inter']
    total = const(float, 0.0)                ['total']
    total.1 = a + b                          ['a', 'b', 'total.1']
    $24return_value.6 = cast(value=total.1)  ['$24return_value.6', 'total.1']
    return $24return_value.6                 ['$24return_value.6']

---------------------------------IR DUMP: adder---------------------------------
label 0:
    a = arg(0, name=a)                       ['a']
    b = arg(1, name=b)                       ['b']
    inter = const(float, 5.0)                ['inter']
    total = const(float, 0.0)                ['total']
    total.1 = a + b                          ['a', 'b', 'total.1']
    $24return_value.6 = cast(value=total.1)  ['$24return_value.6', 'total.1']
    return $24return_value.6                 ['$24return_value.6']

-------------------------------------__main__.adder: nopython: AFTER ir_processing--------------------------------------
label 0:
    a = arg(0, name=a)                       ['a']
    b = arg(1, name=b)                       ['b']
    inter = const(float, 5.0)                ['inter']
    total = const(float, 0.0)                ['total']
    total.1 = a + b                          ['a', 'b', 'total.1']
    $24return_value.6 = cast(value=total.1)  ['$24return_value.6', 'total.1']
    return $24return_value.6                 ['$24return_value.6']

--------------------------------------__main__.adder: nopython: AFTER with_lifting--------------------------------------
label 0:
    a = arg(0, name=a)                       ['a']
    b = arg(1, name=b)                       ['b']
    inter = const(float, 5.0)                ['inter']
    total = const(float, 0.0)                ['total']
    total.1 = a + b                          ['a', 'b', 'total.1']
    $24return_value.6 = cast(value=total.1)  ['$24return_value.6', 'total.1']
    return $24return_value.6                 ['$24return_value.6']

----------------------------------__main__.adder: nopython: AFTER inline_closure_likes----------------------------------
label 0:
    a = arg(0, name=a)                       ['a']
    b = arg(1, name=b)                       ['b']
    inter = const(float, 5.0)                ['inter']
    total = const(float, 0.0)                ['total']
    total.1 = a + b                          ['a', 'b', 'total.1']
    $24return_value.6 = cast(value=total.1)  ['$24return_value.6', 'total.1']
    return $24return_value.6                 ['$24return_value.6']

-------------------------------__main__.adder: nopython: AFTER rewrite_semantic_constants-------------------------------
label 0:
    a = arg(0, name=a)                       ['a']
    b = arg(1, name=b)                       ['b']
    inter = const(float, 5.0)                ['inter']
    total = const(float, 0.0)                ['total']
    total.1 = a + b                          ['a', 'b', 'total.1']
    $24return_value.6 = cast(value=total.1)  ['$24return_value.6', 'total.1']
    return $24return_value.6                 ['$24return_value.6']

-----------------------------------__main__.adder: nopython: AFTER dead_branch_prune------------------------------------
label 0:
    a = arg(0, name=a)                       ['a']
    b = arg(1, name=b)                       ['b']
    inter = const(float, 5.0)                ['inter']
    total = const(float, 0.0)                ['total']
    total.1 = a + b                          ['a', 'b', 'total.1']
    $24return_value.6 = cast(value=total.1)  ['$24return_value.6', 'total.1']
    return $24return_value.6                 ['$24return_value.6']

------------------------------------__main__.adder: nopython: AFTER generic_rewrites------------------------------------
label 0:
    a = arg(0, name=a)                       ['a']
    b = arg(1, name=b)                       ['b']
    inter = const(float, 5.0)                ['inter']
    total = const(float, 0.0)                ['total']
    total.1 = a + b                          ['a', 'b', 'total.1']
    $24return_value.6 = cast(value=total.1)  ['$24return_value.6', 'total.1']
    return $24return_value.6                 ['$24return_value.6']

---------------------------------__main__.adder: nopython: AFTER Rewrite dynamic raises---------------------------------
label 0:
    a = arg(0, name=a)                       ['a']
    b = arg(1, name=b)                       ['b']
    inter = const(float, 5.0)                ['inter']
    total = const(float, 0.0)                ['total']
    total.1 = a + b                          ['a', 'b', 'total.1']
    $24return_value.6 = cast(value=total.1)  ['$24return_value.6', 'total.1']
    return $24return_value.6                 ['$24return_value.6']

-------------------------__main__.adder: nopython: AFTER make_function_op_code_to_jit_function--------------------------
label 0:
    a = arg(0, name=a)                       ['a']
    b = arg(1, name=b)                       ['b']
    inter = const(float, 5.0)                ['inter']
    total = const(float, 0.0)                ['total']
    total.1 = a + b                          ['a', 'b', 'total.1']
    $24return_value.6 = cast(value=total.1)  ['$24return_value.6', 'total.1']
    return $24return_value.6                 ['$24return_value.6']

-----------------------------------__main__.adder: nopython: AFTER inline_inlinables------------------------------------
label 0:
    a = arg(0, name=a)                       ['a']
    b = arg(1, name=b)                       ['b']
    inter = const(float, 5.0)                ['inter']
    total = const(float, 0.0)                ['total']
    total.1 = a + b                          ['a', 'b', 'total.1']
    $24return_value.6 = cast(value=total.1)  ['$24return_value.6', 'total.1']
    return $24return_value.6                 ['$24return_value.6']

-----------------------------------__main__.adder: nopython: AFTER dead_branch_prune------------------------------------
label 0:
    a = arg(0, name=a)                       ['a']
    b = arg(1, name=b)                       ['b']
    inter = const(float, 5.0)                ['inter']
    total = const(float, 0.0)                ['total']
    total.1 = a + b                          ['a', 'b', 'total.1']
    $24return_value.6 = cast(value=total.1)  ['$24return_value.6', 'total.1']
    return $24return_value.6                 ['$24return_value.6']

-------------------------------------__main__.adder: nopython: AFTER find_literally-------------------------------------
label 0:
    a = arg(0, name=a)                       ['a']
    b = arg(1, name=b)                       ['b']
    inter = const(float, 5.0)                ['inter']
    total = const(float, 0.0)                ['total']
    total.1 = a + b                          ['a', 'b', 'total.1']
    $24return_value.6 = cast(value=total.1)  ['$24return_value.6', 'total.1']
    return $24return_value.6                 ['$24return_value.6']

-------------------------------------__main__.adder: nopython: AFTER literal_unroll-------------------------------------
label 0:
    a = arg(0, name=a)                       ['a']
    b = arg(1, name=b)                       ['b']
    inter = const(float, 5.0)                ['inter']
    total = const(float, 0.0)                ['total']
    total.1 = a + b                          ['a', 'b', 'total.1']
    $24return_value.6 = cast(value=total.1)  ['$24return_value.6', 'total.1']
    return $24return_value.6                 ['$24return_value.6']

------------------------------------__main__.adder: nopython: AFTER reconstruct_ssa-------------------------------------
label 0:
    a = arg(0, name=a)                       ['a']
    b = arg(1, name=b)                       ['b']
    inter = const(float, 5.0)                ['inter']
    total = const(float, 0.0)                ['total']
    total.1 = a + b                          ['a', 'b', 'total.1']
    $24return_value.6 = cast(value=total.1)  ['$24return_value.6', 'total.1']
    return $24return_value.6                 ['$24return_value.6']

-----------------------------------__main__.adder: nopython: AFTER LiteralPropagation-----------------------------------
label 0:
    a = arg(0, name=a)                       ['a']
    b = arg(1, name=b)                       ['b']
    inter = const(float, 5.0)                ['inter']
    total = const(float, 0.0)                ['total']
    total.1 = a + b                          ['a', 'b', 'total.1']
    $24return_value.6 = cast(value=total.1)  ['$24return_value.6', 'total.1']
    return $24return_value.6                 ['$24return_value.6']

--------------------------------__main__.adder: nopython: AFTER nopython_type_inference---------------------------------
label 0:
    a = arg(0, name=a)                       ['a']
    b = arg(1, name=b)                       ['b']
    inter = const(float, 5.0)                ['inter']
    total = const(float, 0.0)                ['total']
    total.1 = a + b                          ['a', 'b', 'total.1']
    $24return_value.6 = cast(value=total.1)  ['$24return_value.6', 'total.1']
    return $24return_value.6                 ['$24return_value.6']

---------------------------------------__main__.adder: nopython: AFTER strip_phis---------------------------------------
label 0:
    a = arg(0, name=a)                       ['a']
    b = arg(1, name=b)                       ['b']
    inter = const(float, 5.0)                ['inter']
    total = const(float, 0.0)                ['total']
    total.1 = a + b                          ['a', 'b', 'total.1']
    $24return_value.6 = cast(value=total.1)  ['$24return_value.6', 'total.1']
    return $24return_value.6                 ['$24return_value.6']

------------------------------------__main__.adder: nopython: AFTER inline_overloads------------------------------------
label 0:
    a = arg(0, name=a)                       ['a']
    b = arg(1, name=b)                       ['b']
    inter = const(float, 5.0)                ['inter']
    total = const(float, 0.0)                ['total']
    total.1 = a + b                          ['a', 'b', 'total.1']
    $24return_value.6 = cast(value=total.1)  ['$24return_value.6', 'total.1']
    return $24return_value.6                 ['$24return_value.6']

-----------------------------------__main__.adder: nopython: AFTER nopython_rewrites------------------------------------
label 0:
    a = arg(0, name=a)                       ['a']
    b = arg(1, name=b)                       ['b']
    inter = const(float, 5.0)                ['inter']
    total = const(float, 0.0)                ['total']
    total.1 = a + b                          ['a', 'b', 'total.1']
    $24return_value.6 = cast(value=total.1)  ['$24return_value.6', 'total.1']
    return $24return_value.6                 ['$24return_value.6']

-------------------------__main__.adder: nopython: AFTER nopython_supported_feature_validation--------------------------
label 0:
    a = arg(0, name=a)                       ['a']
    b = arg(1, name=b)                       ['b']
    inter = const(float, 5.0)                ['inter']
    total = const(float, 0.0)                ['total']
    total.1 = a + b                          ['a', 'b', 'total.1']
    $24return_value.6 = cast(value=total.1)  ['$24return_value.6', 'total.1']
    return $24return_value.6                 ['$24return_value.6']

------------------------------------__main__.adder: nopython: AFTER ir_legalization-------------------------------------
label 0:
    a = arg(0, name=a)                       ['a']
    b = arg(1, name=b)                       ['b']
    inter = const(float, 5.0)                ['inter']
    del inter                                []
    total = const(float, 0.0)                ['total']
    del total                                []
    total.1 = a + b                          ['a', 'b', 'total.1']
    del b                                    []
    del a                                    []
    $24return_value.6 = cast(value=total.1)  ['$24return_value.6', 'total.1']
    del total.1                              []
    return $24return_value.6                 ['$24return_value.6']

-------------------------------------__main__.adder: nopython: AFTER annotate_types-------------------------------------
label 0:
    a = arg(0, name=a)                       ['a']
    b = arg(1, name=b)                       ['b']
    inter = const(float, 5.0)                ['inter']
    del inter                                []
    total = const(float, 0.0)                ['total']
    del total                                []
    total.1 = a + b                          ['a', 'b', 'total.1']
    del b                                    []
    del a                                    []
    $24return_value.6 = cast(value=total.1)  ['$24return_value.6', 'total.1']
    del total.1                              []
    return $24return_value.6                 ['$24return_value.6']

------------------------------------__main__.adder: nopython: AFTER native_lowering-------------------------------------
label 0:
    a = arg(0, name=a)                       ['a']
    b = arg(1, name=b)                       ['b']
    inter = const(float, 5.0)                ['inter']
    del inter                                []
    total = const(float, 0.0)                ['total']
    del total                                []
    total.1 = a + b                          ['a', 'b', 'total.1']
    del b                                    []
    del a                                    []
    $24return_value.6 = cast(value=total.1)  ['$24return_value.6', 'total.1']
    del total.1                              []
    return $24return_value.6                 ['$24return_value.6']

------------------------------------__main__.adder: nopython: AFTER nopython_backend------------------------------------
label 0:
    a = arg(0, name=a)                       ['a']
    b = arg(1, name=b)                       ['b']
    inter = const(float, 5.0)                ['inter']
    del inter                                []
    total = const(float, 0.0)                ['total']
    del total                                []
    total.1 = a + b                          ['a', 'b', 'total.1']
    del b                                    []
    del a                                    []
    $24return_value.6 = cast(value=total.1)  ['$24return_value.6', 'total.1']
    del total.1                              []
    return $24return_value.6                 ['$24return_value.6']

--------------------------------__main__.adder: nopython: AFTER dump_parfor_diagnostics---------------------------------
label 0:
    a = arg(0, name=a)                       ['a']
    b = arg(1, name=b)                       ['b']
    inter = const(float, 5.0)                ['inter']
    del inter                                []
    total = const(float, 0.0)                ['total']
    del total                                []
    total.1 = a + b                          ['a', 'b', 'total.1']
    del b                                    []
    del a                                    []
    $24return_value.6 = cast(value=total.1)  ['$24return_value.6', 'total.1']
    del total.1                              []
    return $24return_value.6                 ['$24return_value.6']

Great question @wearone .
If dead code elimination is done by LLVM it will not be visible in the Numba IR but in LLVM IR.
Reconstructing Numba IR from the LLVM IR after optimizations is probably pretty tricky and not very practical. This is because LLVM applies a lot of transformations like inlining, constant folding, and dead code elimination, which can make it hard to see the original structure of the program. Once LLVM has done its optimizations, a lot of the original Numba IR is lost.
One very important question when dealing with arrays would be whether SIMD optimizations are applied properly during the LLVM process. However, these low-level optimizations wouldn’t show up in the original Numba IR, since it’s more abstract and doesn’t usually expose these kinds of details.
The Numba tools to inspect lower level optimizations would be inspect_asm or inspect_llvm or NUMBA_DUMP_OPTIMIZED. Are there other more human-friendly options to inspect optimized code provided by Numba @gmarkall ?