Backport More constant folding with operands disappearing.

Their side-effects must be preserved.

(cherry picked from commit 4bf3c58462fea7d171dd5402f2331e6aef7e7efd)

Conflicts:

	tools/shared/src/main/scala/scala/scalajs/tools/optimizer/OptimizerCore.scala