ir_opt/verification_pass: Eliminate redundant GetArg()

Given the same argument is used inside the condition's body if it's
true, we can just utilize the local to cut out a GetArg() operation.
Avoids redundant internal assertion checking.
This commit is contained in:
Lioncash 2019-05-04 19:07:41 -04:00 committed by MerryMage
parent f4990a5f6b
commit fc9c59d056

View file

@ -31,8 +31,9 @@ void VerificationPass(const IR::Block& block) {
std::map<IR::Inst*, size_t> actual_uses;
for (const auto& inst : block) {
for (size_t i = 0; i < inst.NumArgs(); i++) {
if (!inst.GetArg(i).IsImmediate()) {
actual_uses[inst.GetArg(i).GetInst()]++;
const auto arg = inst.GetArg(i);
if (!arg.IsImmediate()) {
actual_uses[arg.GetInst()]++;
}
}
}