Skip to content

Commit

Permalink
compiler: mark loads of kernel constant attributes as load invariant.
Browse files Browse the repository at this point in the history
Also, enable LICM, since it can take advantage of this.
  • Loading branch information
whitequark committed Mar 28, 2016
1 parent 507ad96 commit 418f0a5
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions artiq/compiler/targets.py
Original file line number Diff line number Diff line change
@@ -105,6 +105,7 @@ def optimize(self, llmodule):
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()
4 changes: 3 additions & 1 deletion artiq/compiler/transforms/llvm_ir_generator.py
Original file line number Diff line number Diff line change
@@ -796,7 +796,9 @@ def process_GetAttr(self, insn):
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

0 comments on commit 418f0a5

Please sign in to comment.