[llvm] 5752538 - [LoopDeletion] Require loop to have a predecessor when executing 1st iteration symbolically
Max Kazantsev via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 21 22:21:19 PDT 2021
Author: Max Kazantsev
Date: 2021-06-22T12:20:55+07:00
New Revision: 575253887bccb8732b901608dabcec3d60324cf0
URL: https://github.com/llvm/llvm-project/commit/575253887bccb8732b901608dabcec3d60324cf0
DIFF: https://github.com/llvm/llvm-project/commit/575253887bccb8732b901608dabcec3d60324cf0.diff
LOG: [LoopDeletion] Require loop to have a predecessor when executing 1st iteration symbolically
Two predecessors break the further logic, and the loop may come to the
opt in non-canonicalized state.
Added:
llvm/test/Transforms/LoopDeletion/two-predecessors.ll
Modified:
llvm/lib/Transforms/Scalar/LoopDeletion.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/LoopDeletion.cpp b/llvm/lib/Transforms/Scalar/LoopDeletion.cpp
index 4d7925e066b20..33572e30f0114 100644
--- a/llvm/lib/Transforms/Scalar/LoopDeletion.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopDeletion.cpp
@@ -206,9 +206,10 @@ static bool canProveExitOnFirstIteration(Loop *L, DominatorTree &DT,
if (!EnableSymbolicExecution)
return false;
+ BasicBlock *Predecessor = L->getLoopPredecessor();
BasicBlock *Latch = L->getLoopLatch();
- if (!Latch)
+ if (!Predecessor || !Latch)
return false;
LoopBlocksRPO RPOT(L);
diff --git a/llvm/test/Transforms/LoopDeletion/two-predecessors.ll b/llvm/test/Transforms/LoopDeletion/two-predecessors.ll
new file mode 100644
index 0000000000000..0a9a62f9a44bb
--- /dev/null
+++ b/llvm/test/Transforms/LoopDeletion/two-predecessors.ll
@@ -0,0 +1,32 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -loop-deletion -S | FileCheck %s
+
+target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
+target triple = "aarch64-unknown-linux-gnu"
+
+define dso_local i32 @hoge() local_unnamed_addr #0 {
+; CHECK-LABEL: @hoge(
+; CHECK-NEXT: bb:
+; CHECK-NEXT: callbr void asm sideeffect "", "X"(i8* blockaddress(@hoge, [[BB2:%.*]]))
+; CHECK-NEXT: to label [[BB1:%.*]] [label %bb2]
+; CHECK: bb1:
+; CHECK-NEXT: br label [[BB2]]
+; CHECK: bb2:
+; CHECK-NEXT: [[TMP:%.*]] = phi i32 [ undef, [[BB1]] ], [ [[TMP3:%.*]], [[BB2]] ], [ undef, [[BB:%.*]] ]
+; CHECK-NEXT: [[TMP3]] = tail call i32 bitcast (i32 (...)* @widget to i32 (i32)*)(i32 [[TMP]])
+; CHECK-NEXT: br label [[BB2]]
+;
+bb:
+ callbr void asm sideeffect "", "X"(i8* blockaddress(@hoge, %bb2)) #1
+ to label %bb1 [label %bb2]
+
+bb1: ; preds = %bb
+ br label %bb2
+
+bb2: ; preds = %bb2, %bb1, %bb
+ %tmp = phi i32 [ undef, %bb1 ], [ %tmp3, %bb2 ], [ undef, %bb ]
+ %tmp3 = tail call i32 bitcast (i32 (...)* @widget to i32 (i32)*)(i32 %tmp) #1
+ br label %bb2
+}
+
+declare dso_local i32 @widget(...) local_unnamed_addr #0
More information about the llvm-commits
mailing list