From ad5ab9f2704f5f686f2a04e8d63777f3b9735d16 Mon Sep 17 00:00:00 2001 From: Anders Schack-Mulligen Date: Wed, 4 Mar 2026 10:56:51 +0100 Subject: [PATCH] Gaurds: Improve perf of forall in guardDeterminesPhiInput. --- shared/controlflow/codeql/controlflow/Guards.qll | 3 +++ 1 file changed, 3 insertions(+) diff --git a/shared/controlflow/codeql/controlflow/Guards.qll b/shared/controlflow/codeql/controlflow/Guards.qll index 9a4f65bcd53..9d7147a1bcb 100644 --- a/shared/controlflow/codeql/controlflow/Guards.qll +++ b/shared/controlflow/codeql/controlflow/Guards.qll @@ -641,6 +641,9 @@ module Make< ) { exists(GuardValue dv, SsaExplicitWrite inp | guardControlsPhiBranch(guard, v, phi, inp) and + // The `forall` below implies that there's only one such `inp` guarded by `guard == v`, + // but checking this upfront improves performance of the `forall` check. + 1 = strictcount(SsaDefinition inp0 | guardControlsPhiBranch(guard, v, phi, inp0)) and inp.getValue() = input and dv = v.getDualValue() and forall(SsaDefinition other | phi.hasInputFromBlock(other, _) and other != inp |