Fix or/sc optimization with non flat contracts.

or/sc cannot optimize away all contracts if one is any/sc, because some
of the values passing through the contract barrier may still need the
protection of the other contracts.

Closes PR 14581.