[llvm] [ValueTracking] Filter out non-interesting conditions (PR #118493)

Andreas Jonson via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 6 10:46:01 PST 2024


================
@@ -18,18 +18,34 @@
 #define LLVM_ANALYSIS_DOMCONDITIONCACHE_H
 
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/BitmaskEnum.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/SmallVector.h"
+#include <cstdint>
 
 namespace llvm {
 
 class Value;
 class BranchInst;
 
+enum class DomConditionFlag : uint8_t {
+  None = 0,
+  KnownBits = 1 << 0,
+  KnownFPClass = 1 << 1,
+  PowerOfTwo = 1 << 2,
+  ICmp = 1 << 3,
+};
+
+LLVM_DECLARE_ENUM_AS_BITMASK(
+    DomConditionFlag,
+    /*LargestValue=*/static_cast<uint8_t>(DomConditionFlag::ICmp));
+
 class DomConditionCache {
 private:
   /// A map of values about which a branch might be providing information.
-  using AffectedValuesMap = DenseMap<Value *, SmallVector<BranchInst *, 1>>;
+  using AffectedValuesMap =
----------------
andjo403 wrote:

as it seems like conditionsFor is called for one DomConditionFlag value maybe better add the flag as en argument and change map to store the flag as part of the key to the map?
DenseMap<std::pair<Value *, DomConditionFlag>, SmallVector<BranchInst *, 1>>;

https://github.com/llvm/llvm-project/pull/118493


More information about the llvm-commits mailing list