[PATCH] D144699: [llvm][Uniformity] provide overloads for Instruction* and Value*
Sameer Sahasrabuddhe via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 23 22:42:43 PST 2023
sameerds created this revision.
Herald added a project: All.
sameerds requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D144699
Files:
llvm/include/llvm/ADT/GenericUniformityImpl.h
llvm/include/llvm/ADT/GenericUniformityInfo.h
Index: llvm/include/llvm/ADT/GenericUniformityInfo.h
===================================================================
--- llvm/include/llvm/ADT/GenericUniformityInfo.h
+++ llvm/include/llvm/ADT/GenericUniformityInfo.h
@@ -62,6 +62,13 @@
/// 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;
Index: llvm/include/llvm/ADT/GenericUniformityImpl.h
===================================================================
--- llvm/include/llvm/ADT/GenericUniformityImpl.h
+++ llvm/include/llvm/ADT/GenericUniformityImpl.h
@@ -1264,6 +1264,11 @@
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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144699.500078.patch
Type: text/x-patch
Size: 1422 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230224/27ca10f0/attachment.bin>
More information about the llvm-commits
mailing list