[PATCH] D150861: [AMDGPU][Uniformity] SI_IF and SI_ELSE pseudos are always divergent
Sameer Sahasrabuddhe via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 18 23:20:16 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9615d48540a2: [AMDGPU][Uniformity] SI_IF and SI_ELSE pseudos are always divergent (authored by sameerds).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D150861/new/
https://reviews.llvm.org/D150861
Files:
llvm/include/llvm/ADT/GenericUniformityImpl.h
llvm/lib/Target/AMDGPU/SIInstructions.td
llvm/test/Analysis/UniformityAnalysis/AMDGPU/MIR/control-flow-intrinsics.mir
Index: llvm/test/Analysis/UniformityAnalysis/AMDGPU/MIR/control-flow-intrinsics.mir
===================================================================
--- /dev/null
+++ llvm/test/Analysis/UniformityAnalysis/AMDGPU/MIR/control-flow-intrinsics.mir
@@ -0,0 +1,39 @@
+# RUN: llc -mtriple=amdgcn-- -mcpu=gfx900 -run-pass=print-machine-uniformity -o - %s 2>&1 | FileCheck %s
+
+---
+name: f1
+body: |
+ ; CHECK-LABEL: MachineUniformityInfo for function: f1
+ bb.0:
+ successors: %bb.1, %bb.2
+
+ ; CHECK-NOT: DIVERGENT: %1
+ %1:sreg_64(s64) = G_IMPLICIT_DEF
+ ; CHECK: DIVERGENT: {{.*}} SI_IF
+ %2:sreg_64 = SI_IF %1, %bb.2, implicit-def $exec, implicit-def $scc, implicit $exec
+
+ bb.1:
+ SI_RETURN
+
+ bb.2:
+ G_BR %bb.1
+
+...
+
+---
+name: f2
+body: |
+ ; CHECK-LABEL: MachineUniformityInfo for function: f2
+ bb.0:
+ successors: %bb.1, %bb.2
+
+ ; CHECK-NOT: DIVERGENT: %1
+ %1:sreg_64(s64) = G_IMPLICIT_DEF
+ ; CHECK: DIVERGENT: {{.*}} SI_ELSE
+ %2:sreg_64 = SI_ELSE %1, %bb.2, implicit-def $exec, implicit-def $scc, implicit $exec
+
+ bb.1:
+ SI_RETURN
+
+ bb.2:
+ G_BR %bb.1
Index: llvm/lib/Target/AMDGPU/SIInstructions.td
===================================================================
--- llvm/lib/Target/AMDGPU/SIInstructions.td
+++ llvm/lib/Target/AMDGPU/SIInstructions.td
@@ -397,6 +397,7 @@
let Constraints = "";
let Size = 12;
let hasSideEffects = 1;
+ let IsNeverUniform = 1;
}
def SI_ELSE : CFPseudoInstSI <
@@ -404,6 +405,7 @@
(ins SReg_1:$src, brtarget:$target), [], 1, 1> {
let Size = 12;
let hasSideEffects = 1;
+ let IsNeverUniform = 1;
}
def SI_WATERFALL_LOOP : CFPseudoInstSI <
Index: llvm/include/llvm/ADT/GenericUniformityImpl.h
===================================================================
--- llvm/include/llvm/ADT/GenericUniformityImpl.h
+++ llvm/include/llvm/ADT/GenericUniformityImpl.h
@@ -1147,9 +1147,11 @@
void GenericUniformityAnalysisImpl<ContextT>::print(raw_ostream &OS) const {
bool haveDivergentArgs = false;
- if (DivergentValues.empty()) {
- assert(DivergentTermBlocks.empty());
- assert(DivergentExitCycles.empty());
+ // Control flow instructions may be divergent even if their inputs are
+ // uniform. Thus, although exceedingly rare, it is possible to have a program
+ // with no divergent values but with divergent control structures.
+ if (DivergentValues.empty() && DivergentTermBlocks.empty() &&
+ DivergentExitCycles.empty()) {
OS << "ALL VALUES UNIFORM\n";
return;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150861.523662.patch
Type: text/x-patch
Size: 2584 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230519/9927bd6f/attachment.bin>
More information about the llvm-commits
mailing list