- lhs_merged = self.with_offset_to_match(
- cr_lhs.ssa_val, additional_offset=-cr_lhs.reg_idx)
- if lhs_loc is not None:
- lhs_merged = lhs_merged.with_loc(lhs_loc)
- rhs_merged = rhs.with_offset_to_match(
- cr_rhs.ssa_val, additional_offset=-cr_rhs.reg_idx)
- if rhs_loc is not None:
- rhs_merged = rhs_merged.with_loc(rhs_loc)
- return lhs_merged.merged(rhs_merged).normalized()
+ return self.__try_copy_merged(lhs_loc=lhs_loc, cr_lhs=cr_lhs,
+ rhs=rhs, rhs_loc=rhs_loc, cr_rhs=cr_rhs)
+
+ @lru_cache(maxsize=None, typed=True)
+ def __try_copy_merged(self, lhs_loc, # type: Loc | None
+ cr_lhs, # type: SSAValSubReg
+ rhs, # type: MergedSSAVal
+ rhs_loc, # type: Loc | None
+ cr_rhs, # type: SSAValSubReg
+ ):
+ # type: (...) -> MergedSSAVal | BadMergedSSAVal
+ try:
+ lhs_merged = self.with_offset_to_match(
+ cr_lhs.ssa_val, additional_offset=-cr_lhs.reg_idx)
+ if lhs_loc is not None:
+ lhs_merged = lhs_merged.with_loc(lhs_loc)
+ rhs_merged = rhs.with_offset_to_match(
+ cr_rhs.ssa_val, additional_offset=-cr_rhs.reg_idx)
+ if rhs_loc is not None:
+ rhs_merged = rhs_merged.with_loc(rhs_loc)
+ return lhs_merged.merged(rhs_merged).normalized()
+ except BadMergedSSAVal as e:
+ return e