[llvm] 3e03cd8 - [llvm][Uniformity] provide overloads for Instruction* and Value*
Sameer Sahasrabuddhe via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 27 21:59:49 PST 2023
Author: Sameer Sahasrabuddhe
Date: 2023-02-28T11:29:19+05:30
New Revision: 3e03cd87b8768091790e019489487fb986b9ffef
URL: https://github.com/llvm/llvm-project/commit/3e03cd87b8768091790e019489487fb986b9ffef
DIFF: https://github.com/llvm/llvm-project/commit/3e03cd87b8768091790e019489487fb986b9ffef.diff
LOG: [llvm][Uniformity] provide overloads for Instruction* and Value*
Uniformity analysis is mainly concerned with the uniformity of values. But it is
sometimes useful to ask if an instruction is uniform, for example, if the
instruction is a terminator. On LLVM IR, every Instruction is a Value, so the
queries like isUniform() need to be overloaded so that the most derived class
always wins.
Reviewed By: ruiling
Differential Revision: https://reviews.llvm.org/D144699
Added:
Modified:
llvm/include/llvm/ADT/GenericUniformityImpl.h
llvm/include/llvm/ADT/GenericUniformityInfo.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/ADT/GenericUniformityImpl.h b/llvm/include/llvm/ADT/GenericUniformityImpl.h
index fd86c533f4e27..294edfba113da 100644
--- a/llvm/include/llvm/ADT/GenericUniformityImpl.h
+++ b/llvm/include/llvm/ADT/GenericUniformityImpl.h
@@ -1264,6 +1264,11 @@ bool GenericUniformityInfo<ContextT>::isDivergent(ConstValueRefT V) const {
return DA->isDivergent(V);
}
+template <typename ContextT>
+bool GenericUniformityInfo<ContextT>::isDivergent(const InstructionT *I) const {
+ return DA->isDivergent(*I);
+}
+
template <typename ContextT>
bool GenericUniformityInfo<ContextT>::hasDivergentTerminator(const BlockT &B) {
return DA->hasDivergentTerminator(B);
diff --git a/llvm/include/llvm/ADT/GenericUniformityInfo.h b/llvm/include/llvm/ADT/GenericUniformityInfo.h
index 5040b7e0797ad..987239d2c2b08 100644
--- a/llvm/include/llvm/ADT/GenericUniformityInfo.h
+++ b/llvm/include/llvm/ADT/GenericUniformityInfo.h
@@ -62,6 +62,13 @@ template <typename ContextT> class GenericUniformityInfo {
/// Whether \p V is uniform/non-divergent.
bool isUniform(ConstValueRefT V) const { return !isDivergent(V); }
+ // Similar queries for InstructionT. These accept a pointer argument so that
+ // in LLVM IR, they overload the equivalent queries for Value*. For example,
+ // if querying whether a BranchInst is divergent, it should not be treated as
+ // a Value in LLVM IR.
+ bool isUniform(const InstructionT *I) const { return !isDivergent(I); };
+ bool isDivergent(const InstructionT *I) const;
+
bool hasDivergentTerminator(const BlockT &B);
void print(raw_ostream &Out) const;
More information about the llvm-commits
mailing list