def transitive_imply(self, other, opt, loop): if self.op.getopnum() != other.op.getopnum(): # stronger restriction, intermixing e.g. <= and < would be possible return None if self.getleftkey() is not other.getleftkey(): return None if not self.rhs.is_identity(): # stronger restriction return None # this is a valid transitive guard that eliminates the loop guard opnum = self.transitive_cmpop(self.cmp_op.getopnum()) box_rhs = self.emit_varops(opt, self.rhs, self.cmp_op.getarg(1)) other_rhs = self.emit_varops(opt, other.rhs, other.cmp_op.getarg(1)) compare = ResOperation(opnum, [box_rhs, other_rhs]) opt.emit_operation(compare) # guard descr = CompileLoopVersionDescr() descr.copy_all_attributes_from(self.op.getdescr()) descr.rd_vector_info = None # do not copy the accum list assert isinstance(descr, AbstractFailDescr) guard = ResOperation(self.op.getopnum(), [compare], descr=descr) guard.setfailargs(loop.label.getarglist_copy()) opt.emit_operation(guard) return guard
def mark_guard(self, node, loop): """ Marks this guard as an early exit! """ op = node.getoperation() assert isinstance(op, GuardResOp) if op.getopnum() in (rop.GUARD_TRUE, rop.GUARD_FALSE): descr = CompileLoopVersionDescr() if op.getdescr(): descr.copy_all_attributes_from(op.getdescr()) op.setdescr(descr) op.setfailargs(loop.label.getarglist_copy())
def mark_guard(self, node, loop): """ Marks this guard as an early exit! """ op = node.getoperation() assert isinstance(op, GuardResOp) if op.getopnum() in (rop.GUARD_TRUE, rop.GUARD_FALSE): descr = CompileLoopVersionDescr() olddescr = op.getdescr() if olddescr: descr.copy_all_attributes_from(olddescr) op.setdescr(descr) arglistcopy = loop.label.getarglist_copy() if not we_are_translated(): for arg in arglistcopy: assert not arg.is_constant() op.setfailargs(arglistcopy)