ExprsToRewrite is used to expand subexpressions, but it is unnecessary
and its purpose is not obvious. I changed the Guards Visitor so that it
can expand subexpressions in a single visit traversal. I think this
makes applyLoopGuards() much easier to read.
This change is not NFC. For urem guards, we directly overwrite
RewriteMap[LHS], but for other guards we write RewriteMap[RewrittenLHS].
Fix urem guards to do the same as other guards. In other words, expand
rewrites on top of existing rewrites, rather than completely overwrite
I was not able to write a testcase for this change using
print<scalar-evolution> output. Manual dbgs() for this change verifies
that urem rewrites does not overwrite other rewrites.
For example, given:
%u = urem i32 %num, 4 %cmp = icmp eq i32 %u, 0 tail call void @llvm.assume(i1 %cmp) %cmp.1 = icmp uge i32 %num, 4 tail call void @llvm.assume(i1 %cmp.1) br label %for.body
The uge was getting overwritten by the urem. This change ensures both
assumes are applied.