From fc9c59d05677e02e208e674c32739e158d05e790 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 4 May 2019 19:07:41 -0400 Subject: [PATCH] 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. --- src/ir_opt/verification_pass.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ir_opt/verification_pass.cpp b/src/ir_opt/verification_pass.cpp index ed99e127..59f474b3 100644 --- a/src/ir_opt/verification_pass.cpp +++ b/src/ir_opt/verification_pass.cpp @@ -31,8 +31,9 @@ void VerificationPass(const IR::Block& block) { std::map 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()]++; } } }