[PATCH] D58192: [LoopUnrollPeel] Add case where we should forget the peeled loop from SCEV.
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 14 05:59:30 PST 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354031: [LoopUnrollPeel] Add case where we should forget the peeled loop from SCEV. (authored by fhahn, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D58192?vs=186827&id=186831#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D58192/new/
https://reviews.llvm.org/D58192
Files:
llvm/trunk/lib/Transforms/Utils/LoopUnrollPeel.cpp
llvm/trunk/test/Transforms/LoopUnroll/peel-loop-scev-invalidate.ll
Index: llvm/trunk/lib/Transforms/Utils/LoopUnrollPeel.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Utils/LoopUnrollPeel.cpp
+++ llvm/trunk/lib/Transforms/Utils/LoopUnrollPeel.cpp
@@ -664,16 +664,14 @@
LatchBR->setMetadata(LLVMContext::MD_prof, WeightNode);
}
- // If the loop is nested, we changed the parent loop, update SE.
- if (Loop *ParentLoop = L->getParentLoop()) {
- SE->forgetLoop(ParentLoop);
-
- // FIXME: Incrementally update loop-simplify
- simplifyLoop(ParentLoop, DT, LI, SE, AC, PreserveLCSSA);
- } else {
- // FIXME: Incrementally update loop-simplify
- simplifyLoop(L, DT, LI, SE, AC, PreserveLCSSA);
- }
+ if (Loop *ParentLoop = L->getParentLoop())
+ L = ParentLoop;
+
+ // We modified the loop, update SE.
+ SE->forgetTopmostLoop(L);
+
+ // FIXME: Incrementally update loop-simplify
+ simplifyLoop(L, DT, LI, SE, AC, PreserveLCSSA);
NumPeeled++;
Index: llvm/trunk/test/Transforms/LoopUnroll/peel-loop-scev-invalidate.ll
===================================================================
--- llvm/trunk/test/Transforms/LoopUnroll/peel-loop-scev-invalidate.ll
+++ llvm/trunk/test/Transforms/LoopUnroll/peel-loop-scev-invalidate.ll
@@ -0,0 +1,42 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -S -loop-unroll -unroll-force-peel-count=1 -verify-scev -verify-dom-info | FileCheck %s
+
+
+define void @test1(i32 %k) {
+; CHECK-LABEL: @test1(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[FOR_BODY_PEEL_BEGIN:%.*]]
+; CHECK: for.body.peel.begin:
+; CHECK-NEXT: br label [[FOR_BODY_PEEL:%.*]]
+; CHECK: for.body.peel:
+; CHECK-NEXT: [[INC_PEEL:%.*]] = add nsw i32 0, 1
+; CHECK-NEXT: [[CMP_PEEL:%.*]] = icmp ult i32 0, [[K:%.*]]
+; CHECK-NEXT: br i1 [[CMP_PEEL]], label [[FOR_BODY_PEEL_NEXT:%.*]], label [[FOR_END:%.*]]
+; CHECK: for.body.peel.next:
+; CHECK-NEXT: br label [[FOR_BODY_PEEL_NEXT1:%.*]]
+; CHECK: for.body.peel.next1:
+; CHECK-NEXT: br label [[ENTRY_PEEL_NEWPH:%.*]]
+; CHECK: entry.peel.newph:
+; CHECK-NEXT: br label [[FOR_BODY:%.*]]
+; CHECK: for.body:
+; CHECK-NEXT: [[I_05:%.*]] = phi i32 [ [[INC_PEEL]], [[ENTRY_PEEL_NEWPH]] ], [ [[INC:%.*]], [[FOR_BODY]] ]
+; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[I_05]], 1
+; CHECK-NEXT: [[CMP:%.*]] = icmp ult i32 [[I_05]], [[K]]
+; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_END_LOOPEXIT:%.*]], !llvm.loop !0
+; CHECK: for.end.loopexit:
+; CHECK-NEXT: br label [[FOR_END]]
+; CHECK: for.end:
+; CHECK-NEXT: ret void
+;
+entry:
+ br label %for.body
+
+for.body:
+ %i.05 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
+ %inc = add nsw i32 %i.05, 1
+ %cmp = icmp ult i32 %i.05, %k
+ br i1 %cmp, label %for.body, label %for.end
+
+for.end:
+ ret void
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58192.186831.patch
Type: text/x-patch
Size: 2886 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190214/16d0ddbe/attachment.bin>
More information about the llvm-commits
mailing list