[PATCH] D153762: [LoopPeel] Clear dispositions after peeling

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 19 01:40:21 PDT 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa6705053c33c: [LoopPeel] Clear dispositions after peeling (authored by nikic).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153762

Files:
  llvm/lib/Transforms/Utils/LoopPeel.cpp
  llvm/test/Transforms/LoopUnroll/loop-block-disposition-after-loop-peeling.ll


Index: llvm/test/Transforms/LoopUnroll/loop-block-disposition-after-loop-peeling.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/LoopUnroll/loop-block-disposition-after-loop-peeling.ll
@@ -0,0 +1,48 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
+; RUN: opt -S -passes='print<scalar-evolution>,loop(loop-unroll-full)' -verify-scev < %s 2>/dev/null | FileCheck %s
+
+define i32 @test(ptr %arg) {
+; CHECK-LABEL: define i32 @test
+; CHECK-SAME: (ptr [[ARG:%.*]]) {
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    br label [[LOOP_PEEL_BEGIN:%.*]]
+; CHECK:       loop.peel.begin:
+; CHECK-NEXT:    br label [[LOOP_PEEL:%.*]]
+; CHECK:       loop.peel:
+; CHECK-NEXT:    [[LOAD_PEEL:%.*]] = load i32, ptr null, align 4
+; CHECK-NEXT:    br i1 false, label [[LOOP_EXIT:%.*]], label [[LOOP_LATCH_PEEL:%.*]]
+; CHECK:       loop.latch.peel:
+; CHECK-NEXT:    br i1 false, label [[LOOP_EXIT]], label [[LOOP_PEEL_NEXT:%.*]]
+; CHECK:       loop.peel.next:
+; CHECK-NEXT:    br label [[LOOP_PEEL_NEXT1:%.*]]
+; CHECK:       loop.peel.next1:
+; CHECK-NEXT:    br label [[ENTRY_PEEL_NEWPH:%.*]]
+; CHECK:       entry.peel.newph:
+; CHECK-NEXT:    br label [[LOOP:%.*]]
+; CHECK:       loop:
+; CHECK-NEXT:    [[LOAD:%.*]] = load i32, ptr null, align 4
+; CHECK-NEXT:    br i1 false, label [[LOOP_EXIT_LOOPEXIT:%.*]], label [[LOOP_LATCH:%.*]]
+; CHECK:       loop.latch:
+; CHECK-NEXT:    br i1 false, label [[LOOP_EXIT_LOOPEXIT]], label [[LOOP]], !llvm.loop [[LOOP0:![0-9]+]]
+; CHECK:       loop.exit.loopexit:
+; CHECK-NEXT:    [[EXITVAL_PH:%.*]] = phi i32 [ [[LOAD]], [[LOOP]] ], [ 0, [[LOOP_LATCH]] ]
+; CHECK-NEXT:    br label [[LOOP_EXIT]]
+; CHECK:       loop.exit:
+; CHECK-NEXT:    [[EXITVAL:%.*]] = phi i32 [ [[LOAD_PEEL]], [[LOOP_PEEL]] ], [ 0, [[LOOP_LATCH_PEEL]] ], [ [[EXITVAL_PH]], [[LOOP_EXIT_LOOPEXIT]] ]
+; CHECK-NEXT:    ret i32 [[EXITVAL]]
+;
+entry:
+  br label %loop
+
+loop:
+  %iv = phi ptr [ %arg, %loop.latch ], [ null, %entry ]
+  %load = load i32, ptr null, align 4
+  br i1 false, label %loop.exit, label %loop.latch
+
+loop.latch:
+  br i1 false, label %loop.exit, label %loop
+
+loop.exit:
+  %exitval = phi i32 [ 0, %loop.latch ], [ %load, %loop ]
+  ret i32 %exitval
+}
Index: llvm/lib/Transforms/Utils/LoopPeel.cpp
===================================================================
--- llvm/lib/Transforms/Utils/LoopPeel.cpp
+++ llvm/lib/Transforms/Utils/LoopPeel.cpp
@@ -1042,6 +1042,7 @@
 
   // We modified the loop, update SE.
   SE->forgetTopmostLoop(L);
+  SE->forgetBlockAndLoopDispositions();
 
 #ifdef EXPENSIVE_CHECKS
   // Finally DomtTree must be correct.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153762.541893.patch
Type: text/x-patch
Size: 2699 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230719/094e13fa/attachment.bin>


More information about the llvm-commits mailing list