add operand evaluation cache to phi nodes
some phis are really big and have repeated values
this cache ensure all use the same undef, reducing number of quantified vars
MODIFY
ir/instr.cpp
ir/instr.cpp
@@ -1820,10 +1820,16 @@ void Phi::print(ostream &os) const {
StateValue Phi::toSMT(State &s) const {
DisjointExpr<StateValue> ret;
+ map<Value*, StateValue> cache;
+
for (auto &[val, bb] : values) {
// check if this was a jump from unreachable BB
- if (auto pre = s.jumpCondFrom(s.getFn().getBB(bb)))
- ret.add(s[*val], (*pre)());
+ if (auto pre = s.jumpCondFrom(s.getFn().getBB(bb))) {
+ auto [I, inserted] = cache.try_emplace(val);
+ if (inserted)
+ I->second = s[*val];
+ ret.add(I->second, (*pre)());
+ }
}
return *ret();
}

add operand evaluation cache to phi nodes
some phis are really big and have repeated values
this cache ensure all use the same undef, reducing number of quantified vars