offsetMemoryInBodyReturns :: RebaseMap -> BodyReturns -> BodyReturns
offsetMemoryInBodyReturns offsets (MemArray pt shape u (ReturnsInBlock mem ixfun))
  | Just ixfun' <- isStaticIxFun ixfun,
    Just new_base <- lookupNewBase mem (IxFun.base ixfun') offsets =
      MemArray pt shape u $ ReturnsInBlock mem $
      IxFun.rebase (fmap (fmap Free) new_base) ixfun
offsetMemoryInBodyReturns :: RebaseMap -> BodyReturns -> BodyReturns
offsetMemoryInBodyReturns offsets (MemArray pt shape u (ReturnsInBlock mem ixfun))
  | Just ixfun' <- isStaticIxFun ixfun,
    Just new_base <- lookupNewBase mem (IxFun.base ixfun') offsets =
      MemArray pt shape u $ ReturnsInBlock mem $
      IxFun.rebase (fmap (fmap Free) new_base) ixfun
offsetMemoryInBodyReturns offsets (MemArray pt shape u (ReturnsInBlock mem ixfun))
  | Just ixfun' <- isStaticIxFun ixfun,
    Just new_base <- lookupNewBase mem (IxFun.base ixfun') offsets =
      MemArray pt shape u $ ReturnsInBlock mem $
      IxFun.rebase (fmap (fmap Free) new_base) ixfun