From eae90fdc75011f5aee75f33a86d4f4dec93984a3 Mon Sep 17 00:00:00 2001 From: Philip Reames Date: Fri, 27 Aug 2021 10:09:51 -0700 Subject: [PATCH] [test] exercise breakLoopBackedge with a switch latch cond This was reduced from a test case which triggered a revert to my recent change to same function. It turns out we didn't have *any* coverage of the non-branch latch and my patch was blatantly broken. --- llvm/test/Transforms/LoopDeletion/switch.ll | 43 +++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 llvm/test/Transforms/LoopDeletion/switch.ll diff --git a/llvm/test/Transforms/LoopDeletion/switch.ll b/llvm/test/Transforms/LoopDeletion/switch.ll new file mode 100644 index 000000000000..571e31dddfba --- /dev/null +++ b/llvm/test/Transforms/LoopDeletion/switch.ll @@ -0,0 +1,43 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; RUN: opt < %s -loop-deletion -verify-loop-info -S | FileCheck %s + +target triple = "x86_64-unknown-linux-gnu" + +@G = external global i32 + +define void @func_1() { +; CHECK-LABEL: @func_1( +; CHECK-NEXT: entry: +; CHECK-NEXT: br label [[LBL_2368:%.*]] +; CHECK: lbl_2368: +; CHECK-NEXT: [[CMP289:%.*]] = icmp slt i32 undef, -5 +; CHECK-NEXT: br i1 [[CMP289]], label [[CLEANUP967:%.*]], label [[UNREACHABLE:%.*]] +; CHECK: cleanup967: +; CHECK-NEXT: switch i32 undef, label [[CLEANUP1169:%.*]] [ +; CHECK-NEXT: i32 20, label [[CLEANUP967_LBL_2368_CRIT_EDGE:%.*]] +; CHECK-NEXT: ] +; CHECK: cleanup967.lbl_2368_crit_edge: +; CHECK-NEXT: unreachable +; CHECK: cleanup1169: +; CHECK-NEXT: ret void +; CHECK: unreachable: +; CHECK-NEXT: unreachable +; +entry: + br label %lbl_2368 + +lbl_2368: + %cmp289 = icmp slt i32 undef, -5 + br i1 %cmp289, label %cleanup967, label %unreachable + +cleanup967: + switch i32 undef, label %cleanup1169 [ + i32 20, label %lbl_2368 + ] + +cleanup1169: + ret void + +unreachable: + unreachable +}