1

I wanted to check the LLVM IR for a vector addition from numba and noticed it generates a lot of IR just for a simple add. I was hoping a simple "add" IR but it generates 2000 lines of LLVM IR. Is there a way to get a minimal code?

from numba import jit
import numpy as np

@jit(nopython=True,nogil=True)
def mysum(a,b):
    return a+b

a, b = 1.3 * np.ones(5), 2.2 * np.ones(5)
mysum(a, b)

# Get the llvm IR
llvm_ir =list(mysum.inspect_llvm().values())[0]
print(llvm_ir)
with open("llvm_ir.ll", "w") as file:
    file.write(llvm_ir)

# Get the assembly code
asm = list(mysum.inspect_asm().values())[0]
print(asm)

with open("llvm_ir.asm", "w") as file:
    file.write(asm)
Roy
  • 65
  • 2
  • 15
  • 40
  • Can you please share the IR? I imagine it has to do with handling different types of objects, as it cannot guarantee the inputs are integers. – tekknolagi Mar 14 '23 at 16:15

0 Answers0