[MemCpyOpt] Avoid infinite loop in processMemSetMemCpyDependence (PR54983)
This adds an additional transform to drop zero-size memcpys, also in the case where the size is only zero after instruction simplification. The motivation is the case from PR54983 where the size is non-trivially zero, and processMemSetMemCpyDependence() keeps trying to reduce the memset size by zero bytes. This fix it's not really principled. It only works on the premise that if InstSimplify doesn't realize the size is zero, then AA also won't. The principled approach would be to instead add a isKnownNonZero() guard to the processMemSetMemCpyDependence() transform, but I suspect that would render that optimization mostly useless (at least it breaks all the existing test coverage -- worth noting that the constant size case is also handled by DSE, so I think this transform is primarily about the dynamic size case). Fixes https://github.com/llvm/llvm-project/issues/54983. Fixes https://github.com/llvm/llvm-project/issues/64886. Differential Revision: https://reviews.llvm.org/D124078
Loading
Please sign in to comment