Cast materialization as it occurs in the standard to LLVM lowering does not
support index types. As a result, the generated IR was invalid if a cast to an
index type was introduced. This occurs, e.g., when the standard to LLVM patterns
are combined with a set of patterns that does not rewrite IR in a strictly
sequential order. The lowering from SCF to standard is one such case where the
terminal operation of a loop's body is rewritten before its other operations.
Example:
The simultaneous application of patterns from SCF to standard and from standard
to LLVM rewrites the following to invalid IR.
```
%result = scf.for %i = %c0 to %c1 step %c1 iter_args(%aggr = %c0) {
%c123 = constant 123 : index
scf.yield %c123 : index
}
```
Because `scf.yield` is rewritten before the constant operation the lowering
introduces a cast from index to `i64`. When all patterns were applied, the newly
introduced cast still expects the old type, an index. At this point a second
cast from `i64` to index is introduced (which is invalid by the definition of
the cast operation).
This CL bypasses the creation of such invalid casts.