From 0e0f81b5095f4a86ed7fa8ea2962c2ca28db7a1a Mon Sep 17 00:00:00 2001 From: whitequark Date: Mon, 28 Mar 2016 00:44:32 +0000 Subject: [PATCH] compiler: mark loads of kernel constant attributes as load invariant. Also, enable LICM, since it can take advantage of this. --- artiq/compiler/targets.py | 1 + artiq/compiler/transforms/llvm_ir_generator.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/artiq/compiler/targets.py b/artiq/compiler/targets.py index c936829e9..42f5551b0 100644 --- a/artiq/compiler/targets.py +++ b/artiq/compiler/targets.py @@ -105,6 +105,7 @@ class Target: llpassmgr.add_instruction_combining_pass() llpassmgr.add_gvn_pass() llpassmgr.add_cfg_simplification_pass() + llpassmgr.add_licm_pass() # Clean up after optimizing. llpassmgr.add_dead_arg_elimination_pass() diff --git a/artiq/compiler/transforms/llvm_ir_generator.py b/artiq/compiler/transforms/llvm_ir_generator.py index b2c67875e..fcb3b5d85 100644 --- a/artiq/compiler/transforms/llvm_ir_generator.py +++ b/artiq/compiler/transforms/llvm_ir_generator.py @@ -796,7 +796,9 @@ class LLVMIRGenerator: else: llptr = self.llbuilder.gep(obj, [self.llindex(0), self.llindex(index)], inbounds=True, name="ptr.{}".format(insn.name)) - return self.llbuilder.load(llptr, name="val.{}".format(insn.name)) + llval = self.llbuilder.load(llptr, name="val.{}".format(insn.name)) + llval.metadata['invariant.load'] = self.empty_metadata + return llval def process_SetAttr(self, insn): typ, attr = insn.object().type, insn.attr