[PATCH] D137651: [LoopFlatten] Forget all block and loop dispositions after flatten
luxufan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 8 23:56:20 PST 2022
StephenFan updated this revision to Diff 474168.
StephenFan added a comment.
Add checking lines.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D137651/new/
https://reviews.llvm.org/D137651
Files:
llvm/lib/Transforms/Scalar/LoopFlatten.cpp
llvm/test/Transforms/LoopFlatten/pr58865.ll
Index: llvm/test/Transforms/LoopFlatten/pr58865.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/LoopFlatten/pr58865.ll
@@ -0,0 +1,51 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -loop-flatten -verify-scev -S < %s | FileCheck %s
+;
+define void @sum_2d(ptr %p) {
+; CHECK-LABEL: @sum_2d(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[FLATTEN_TRIPCOUNT:%.*]] = mul i16 1, 1
+; CHECK-NEXT: br label [[OUTER:%.*]]
+; CHECK: outer:
+; CHECK-NEXT: [[SUM_04:%.*]] = phi i16 [ 0, [[ENTRY:%.*]] ], [ [[DOTLCSSA:%.*]], [[OUTER_LATCH:%.*]] ]
+; CHECK-NEXT: [[OUTER_IV:%.*]] = phi i16 [ 0, [[ENTRY]] ], [ [[OUTER_IV_NEXT:%.*]], [[OUTER_LATCH]] ]
+; CHECK-NEXT: br label [[INNER:%.*]]
+; CHECK: inner:
+; CHECK-NEXT: [[SUM_12:%.*]] = phi i16 [ [[SUM_04]], [[OUTER]] ]
+; CHECK-NEXT: [[INNER_IV:%.*]] = phi i16 [ 0, [[OUTER]] ]
+; CHECK-NEXT: [[TMP0:%.*]] = load i16, ptr [[P:%.*]], align 1
+; CHECK-NEXT: [[INNER_IV_NEXT:%.*]] = add nsw i16 [[INNER_IV]], 1
+; CHECK-NEXT: [[CMP2:%.*]] = icmp slt i16 [[INNER_IV]], 0
+; CHECK-NEXT: br label [[OUTER_LATCH]]
+; CHECK: outer.latch:
+; CHECK-NEXT: [[DOTLCSSA]] = phi i16 [ [[TMP0]], [[INNER]] ]
+; CHECK-NEXT: [[OUTER_IV_NEXT]] = add nsw i16 [[OUTER_IV]], 1
+; CHECK-NEXT: [[CMP:%.*]] = icmp slt i16 [[OUTER_IV_NEXT]], [[FLATTEN_TRIPCOUNT]]
+; CHECK-NEXT: br i1 [[CMP]], label [[OUTER]], label [[EXIT:%.*]]
+; CHECK: exit:
+; CHECK-NEXT: ret void
+;
+entry:
+ br label %outer
+
+outer: ; preds = %outer.latch, %entry
+ %sum.04 = phi i16 [ 0, %entry ], [ %0, %outer.latch ]
+ %outer.iv = phi i16 [ 0, %entry ], [ %outer.iv.next, %outer.latch ]
+ br label %inner
+
+inner: ; preds = %inner, %outer
+ %sum.12 = phi i16 [ %sum.04, %outer ], [ %0, %inner ]
+ %inner.iv = phi i16 [ 0, %outer ], [ %inner.iv.next, %inner ]
+ %0 = load i16, ptr %p, align 1
+ %inner.iv.next = add nsw i16 %inner.iv, 1
+ %cmp2 = icmp slt i16 %inner.iv, 0
+ br i1 %cmp2, label %inner, label %outer.latch
+
+outer.latch: ; preds = %inner
+ %outer.iv.next = add nsw i16 %outer.iv, 1
+ %cmp = icmp slt i16 %outer.iv.next, 0
+ br i1 %cmp, label %outer, label %exit
+
+exit: ; preds = %outer.latch
+ ret void
+}
Index: llvm/lib/Transforms/Scalar/LoopFlatten.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/LoopFlatten.cpp
+++ llvm/lib/Transforms/Scalar/LoopFlatten.cpp
@@ -762,6 +762,7 @@
// deleted, and any information that have about the outer loop invalidated.
SE->forgetLoop(FI.OuterLoop);
SE->forgetLoop(FI.InnerLoop);
+ SE->forgetBlockAndLoopDispositions();
if (U)
U->markLoopAsDeleted(*FI.InnerLoop, FI.InnerLoop->getName());
LI->erase(FI.InnerLoop);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137651.474168.patch
Type: text/x-patch
Size: 2982 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221109/9c83b88c/attachment.bin>
More information about the llvm-commits
mailing list