[PATCH] D139601: [LoopDistribute] Clear cache of `LoopAccessInfoManager`

Miguel Saldivar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 7 19:39:06 PST 2022


Saldivarcher created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
Saldivarcher requested review of this revision.
Herald added subscribers: llvm-commits, pcwang-thead.
Herald added a project: LLVM.

As #59319 describes, enabling `LoopDistribute` along with `LoopVectorize` causes an assertion to be hit. The reason seems to be because the `LoopDistribute` pass doesn't clear out the cache of the `LoopAccessInfoManager`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139601

Files:
  llvm/lib/Transforms/Scalar/LoopDistribute.cpp
  llvm/test/Transforms/LoopDistribute/pr59319.ll


Index: llvm/test/Transforms/LoopDistribute/pr59319.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/LoopDistribute/pr59319.ll
@@ -0,0 +1,50 @@
+; RUN: opt -passes=loop-distribute,loop-vectorize -enable-loop-distribute -S \
+; RUN: < %s | FileCheck %s
+; ModuleID = '<bc file>'
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define void @reduced(i32* %0, i32* %1, i64 %indvars.iv, i32* %2, i64 %indvars.iv76, i64 %indvars.iv93) {
+;CHECK-LABEL: @reduced(
+entry:
+  br label %for.body
+
+for.body:                                         ; preds = %for.body, %entry
+  %indvars.iv761 = phi i64 [ 0, %entry ], [ %indvars.iv.next77, %for.body ]
+  %indvars.iv4 = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
+  %indvars.iv.next77 = add i64 %indvars.iv761, 1
+  %arrayidx.i.i50 = getelementptr i32, i32* %0, i64 %indvars.iv76
+  %indvars.iv.next = add i64 %indvars.iv4, 1
+  %exitcond.not = icmp eq i64 %indvars.iv4, %indvars.iv
+  br i1 %exitcond.not, label %for.body13.preheader, label %for.body
+
+for.body13.preheader:                             ; preds = %for.body
+  br label %for.body13
+
+for.body26.lr.ph:                                 ; preds = %for.body13
+  %idxprom.i.i61 = and i64 %indvars.iv761, 1
+  %arrayidx.i.i62 = getelementptr i32, i32* %0, i64 %idxprom.i.i61
+  br label %for.body26
+
+for.body13:                                       ; preds = %for.body13, %for.body13.preheader
+  %indvars.iv846 = phi i64 [ %indvars.iv.next85, %for.body13 ], [ 0, %for.body13.preheader ]
+  %indvars.iv.next87 = add i64 0, 0
+  %arrayidx.i.i56 = getelementptr i32, i32* %0, i64 %indvars.iv761
+  %3 = load i32, i32* %arrayidx.i.i56, align 4
+  store i32 0, i32* %1, align 4
+  %indvars.iv.next85 = add i64 %indvars.iv846, 1
+  %exitcond92.not = icmp eq i64 %indvars.iv846, %indvars.iv
+  br i1 %exitcond92.not, label %for.body26.lr.ph, label %for.body13
+
+for.cond.cleanup25:                               ; preds = %for.body26
+  ret void
+
+for.body26:                                       ; preds = %for.body26, %for.body26.lr.ph
+  %indvars.iv932 = phi i64 [ 0, %for.body26.lr.ph ], [ %indvars.iv.next94, %for.body26 ]
+  %4 = load i32, i32* %arrayidx.i.i62, align 4
+  %arrayidx.i.i653 = getelementptr i32, i32* %2, i64 %indvars.iv93
+  store i32 0, i32* %1, align 4
+  %indvars.iv.next94 = add i64 %indvars.iv932, 1
+  %exitcond97.not = icmp eq i64 %indvars.iv932, %indvars.iv
+  br i1 %exitcond97.not, label %for.cond.cleanup25, label %for.body26
+}
Index: llvm/lib/Transforms/Scalar/LoopDistribute.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/LoopDistribute.cpp
+++ llvm/lib/Transforms/Scalar/LoopDistribute.cpp
@@ -992,6 +992,7 @@
     // enabled/disabled, follow that.  Otherwise use the global flag.
     if (LDL.isForced().value_or(EnableLoopDistribute))
       Changed |= LDL.processLoop();
+    LAIs.clear();
   }
 
   // Process each loop nest in the function.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139601.481142.patch
Type: text/x-patch
Size: 3109 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221208/6188edb4/attachment.bin>


More information about the llvm-commits mailing list