Optimize constant generation