Github issue: Trivial memset optimization not applied to loops under -Oz (LoopIdiomRecognize)
When opt -loop-idiom is run on an LLVM IR file containing a countable unrotated loop containing stores of a simple constant to a single array, a memset optimization is not applied under -Oz or -loop-idiom. The optimization is not applied since runOnLoopBlock stops before the memset optimization is applied on the loop.
runOnLoopBlock stops before the optimization because it checks whether each basic block dominates all exit blocks in the loop. For unrotated loops, this check causes an early return. To work around this, a boolean representing the rotation form of the loop is passed to runOnLoopBlock. Based on the given boolean, the check for domination of the exit blocks is done. Otherwise, the check is skipped and the optimization is applied directly.
I do not understand why we can just not do this check for unrotated loops?