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

Miguel Saldivar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 3 20:00:29 PST 2023


Saldivarcher updated this revision to Diff 486153.
Saldivarcher marked an inline comment as not done.
Saldivarcher retitled this revision from "[LoopDistribute] Clear cache of `LoopAccessInfoManager`" to "[LoopVectorize] Clear cache of `LoopAccessInfoManager`".
Herald added a subscriber: shiva0217.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139601/new/

https://reviews.llvm.org/D139601

Files:
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/test/Transforms/LoopVectorize/pr59319.ll


Index: llvm/test/Transforms/LoopVectorize/pr59319.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/LoopVectorize/pr59319.ll
@@ -0,0 +1,50 @@
+; RUN: opt -passes=loop-distribute,loop-vectorize -enable-loop-distribute -S \
+; RUN: %s | FileCheck %s
+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"
+; REQUIRES: x86-registered-target
+
+define void @reduced(i32* %0, i32* %1, i64 %iv, i32* %2, i64 %iv76, i64 %iv93) {
+; CHECK-LABEL: @reduced(
+entry:
+  br label %loop.1
+
+loop.1:                                         ; preds = %loop.1, %entry
+  %iv761 = phi i64 [ 0, %entry ], [ %iv.next77, %loop.1 ]
+  %iv4 = phi i64 [ 0, %entry ], [ %iv.next, %loop.1 ]
+  %iv.next77 = add i64 %iv761, 1
+  %arrayidx.i.i50 = getelementptr i32, i32* %0, i64 %iv76
+  %iv.next = add i64 %iv4, 1
+  %exitcond.not = icmp eq i64 %iv4, %iv
+  br i1 %exitcond.not, label %loop.2.preheader, label %loop.1
+
+loop.2.preheader:                             ; preds = %loop.1
+  br label %loop.2
+
+loop.3.lr.ph:                                 ; preds = %loop.2
+  %idxprom.i.i61 = and i64 %iv761, 1
+  %arrayidx.i.i62 = getelementptr i32, i32* %0, i64 %idxprom.i.i61
+  br label %loop.3
+
+loop.2:                                       ; preds = %loop.2, %loop.2.preheader
+  %iv846 = phi i64 [ %iv.next85, %loop.2 ], [ 0, %loop.2.preheader ]
+  %iv.next87 = add i64 0, 0
+  %arrayidx.i.i56 = getelementptr i32, i32* %0, i64 %iv761
+  %3 = load i32, i32* %arrayidx.i.i56, align 4
+  store i32 0, i32* %1, align 4
+  %iv.next85 = add i64 %iv846, 1
+  %exitcond92.not = icmp eq i64 %iv846, %iv
+  br i1 %exitcond92.not, label %loop.3.lr.ph, label %loop.2
+
+loop.3:                                       ; preds = %loop.3, %loop.3.lr.ph
+  %iv932 = phi i64 [ 0, %loop.3.lr.ph ], [ %iv.next94, %loop.3 ]
+  %4 = load i32, i32* %arrayidx.i.i62, align 4
+  %arrayidx.i.i653 = getelementptr i32, i32* %2, i64 %iv93
+  store i32 0, i32* %1, align 4
+  %iv.next94 = add i64 %iv932, 1
+  %exitcond97.not = icmp eq i64 %iv932, %iv
+  br i1 %exitcond97.not, label %loop.cleanup, label %loop.3
+
+loop.cleanup:                               ; preds = %loop.3
+  ret void
+}
Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -10599,6 +10599,9 @@
 
   bool Changed = false, CFGChanged = false;
 
+  // Assure that the `LoopAccessManagerInfo` cache is invalidated.
+  LAIs->clear();
+
   // The vectorizer requires loops to be in simplified form.
   // Since simplification may add new inner loops, it has to run before the
   // legality and profitability checks. This means running the loop vectorizer


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139601.486153.patch
Type: text/x-patch
Size: 2899 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230104/eb12c005/attachment.bin>


More information about the llvm-commits mailing list