LLVM cannot optimize out some excessive store in loop/memset when another store in loop later writes to the same memory region
Practically, it might happen in cases like Fail to eliminate deadstore from vector resize when an array/vector is prefilled with some constant and for-loop writes something else there
These use cases basically look like this
for (int i = 0; i < N; ++i) P[i] = 1; for (int i = 0; i < N; ++i) P[i] = 1;
or
memset(P, 0, N * sizeof(int)) for (int i = 0; i < N; ++i) P[i] = 1;
We have already partially solved this problem by LoopIdiomRecognize that transforms loop into memset which DSE can successfully remove like in this example
This patch should only generalize this to cases when LIR fails to transform loop with single basic block like in this example, so we cannot remove a memset because alias analysis gives up here
There are going to be subsequent patches that solve this for more cases so it is incrementally fixed
clang-tidy: warning: do not use 'else' after 'return' [llvm-else-after-return]
not useful