ParameterValueBasedSelectExpressionOptimizer runs InExpressionValuesExpandingExpressionVisitor and FromSqlParameterApplyingExpressionVisitor at query execution (not compilation). We can detect during compilation if these visitors are actually necessary and flow that information to the execution phase.
For example, for queries which don't contain InExpression we wouldn't need to run InExpressionValuesExpandingExpressionVisitor.
See also #16375 which is related.