[optimizing] Improve constant folding on logical and am: 4eb6eb40e8
am: c76e521a66

Change-Id: I4e0a55d50211ece52f677f6ddd54948c4df1e79d