rework optimization passes

A workaround to get #6828 through.