Fix loop optimization in the presence of environment uses.
am: 565cd4e986

Change-Id: Iff2fba0bb62bb22515a91d8ecb1c9c4af71a87a2