1 //===- DomConditionCache.cpp ----------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "llvm/Analysis/DomConditionCache.h"
10 #include "llvm/Analysis/ValueTracking.h"
13 static void findAffectedValues(Value
*Cond
,
14 SmallVectorImpl
<Value
*> &Affected
) {
15 auto InsertAffected
= [&Affected
](Value
*V
) { Affected
.push_back(V
); };
16 findValuesAffectedByCondition(Cond
, /*IsAssume=*/false, InsertAffected
);
19 void DomConditionCache::registerBranch(BranchInst
*BI
) {
20 assert(BI
->isConditional() && "Must be conditional branch");
21 SmallVector
<Value
*, 16> Affected
;
22 findAffectedValues(BI
->getCondition(), Affected
);
23 for (Value
*V
: Affected
) {
24 auto &AV
= AffectedValues
[V
];
25 if (!is_contained(AV
, BI
))