[mlir][Affine] Yield the last unrolled IV when a loop yields its IV (#242641)
When `affine.for` yields its induction value, `affine-loop-unroll` kept
yielding the IV of the first result unrolled copy instead of the last
one, so the loop result was wrong (see #236268 where it gives 0 instead
of 1) and this resulted in a silent miscompile
This was caused by `generateUnrolledLoop` that only updated
`lastYielded` for values defined by an op inside the loop body
(`operandMap.lookup`, see commit 186c3d6315f0) but the IV is a
BlockArgument, so it was getting skipped.
Instead we now use `lookupOrDefault`, so instead of assuming that only
values with `getDefiningOp` are valid, we correctly handle values
defined outside of the loop. This is already done by the
`generateUnrolledLoop` in SCF.
The existing test `@loop_unroll_yield_loop_iv` checked for the old
output, but this PR updates it to check that the last copy's IV is the
one that gets yielded
Fixes #236268
Assisted-By: Claude (formatted PR body, wrote test)