aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib
diff options
context:
space:
mode:
authorMariusz Sikora <mariusz.sikora@amd.com>2024-12-04 08:42:04 +0100
committerGitHub <noreply@github.com>2024-12-04 08:42:04 +0100
commit455b4fd01ae9b2a78be98bcd26db2b700709c545 (patch)
tree88b3f1d506b9078785458e1348291ed4473d7d0a /llvm/lib
parentb1a48af56a62b8c0d5636c9404251700264fcd70 (diff)
downloadllvm-455b4fd01ae9b2a78be98bcd26db2b700709c545.zip
llvm-455b4fd01ae9b2a78be98bcd26db2b700709c545.tar.gz
llvm-455b4fd01ae9b2a78be98bcd26db2b700709c545.tar.bz2
[AMDGPU] Emit amdgcn.if.break in the same BB as amdgcn.loop (#118081)
Before this change if.break was placed in wrong loop level which resulted in accumulating values only from last iteration of the inner loop.
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/AMDGPU/SIAnnotateControlFlow.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/lib/Target/AMDGPU/SIAnnotateControlFlow.cpp b/llvm/lib/Target/AMDGPU/SIAnnotateControlFlow.cpp
index fa39df9..4ff6fc3 100644
--- a/llvm/lib/Target/AMDGPU/SIAnnotateControlFlow.cpp
+++ b/llvm/lib/Target/AMDGPU/SIAnnotateControlFlow.cpp
@@ -224,8 +224,13 @@ Value *SIAnnotateControlFlow::handleLoopCondition(
if (Instruction *Inst = dyn_cast<Instruction>(Cond)) {
BasicBlock *Parent = Inst->getParent();
Instruction *Insert;
- if (L->contains(Inst)) {
+ if (LI->getLoopFor(Parent) == L) {
+ // Insert IfBreak in the same BB as Cond, which can help
+ // SILowerControlFlow to know that it does not have to insert an
+ // AND with EXEC.
Insert = Parent->getTerminator();
+ } else if (L->contains(Inst)) {
+ Insert = Term;
} else {
Insert = L->getHeader()->getFirstNonPHIOrDbgOrLifetime();
}