compact: Try to preserve IR_FLAG_REFINED
In #49340, I added an ir flag (currently only set by sroa) to allow
sparse-reinference of ir after optimization passes that may improve
type information. However, as currently implemented, this flag gets
dropped when the IR is compacted, defeating the purpose of the flag,
because it can no longer be reliably used for sparse re-inference.
This commit changes compact prevent compaction if IR_FLAG_REFINED
is set on a statement. This is the minimal change to fix this issue,
but it is probably suboptimal for the base pipeline, because we
(currently) do not do any re-inference (other than during
semi-concrete eval), so the flag never gets cleared. I think the
viable alternatives are:
1. Be more selective about setting IR_FLAG_REFINED only in situations
where there is an actual improvement in the detected type.
2. Have compact look at whether the original IR statement was refined
and if so, propagate the flag.
3. Both.
However, these are somewhat separate optimizations from fixing
the underlying bug (and indepedent from each other),
so let's experiment with those in separate commits.