Analyzer value cache

Adds some caching mechanisms to avoid crazy run times of const propagation. Fixes #3599.