[llvm] 65390f9 - [SimplifyCFG] Add test for #104567 (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 16 03:37:34 PDT 2024
Author: Nikita Popov
Date: 2024-08-16T12:37:18+02:00
New Revision: 65390f9d6f0aa5f7bc5125d73337eb658e162d0a
URL: https://github.com/llvm/llvm-project/commit/65390f9d6f0aa5f7bc5125d73337eb658e162d0a
DIFF: https://github.com/llvm/llvm-project/commit/65390f9d6f0aa5f7bc5125d73337eb658e162d0a.diff
LOG: [SimplifyCFG] Add test for #104567 (NFC)
Added:
llvm/test/Transforms/SimplifyCFG/sink-and-convert-switch.ll
Modified:
Removed:
################################################################################
diff --git a/llvm/test/Transforms/SimplifyCFG/sink-and-convert-switch.ll b/llvm/test/Transforms/SimplifyCFG/sink-and-convert-switch.ll
new file mode 100644
index 00000000000000..4944554f4b49ec
--- /dev/null
+++ b/llvm/test/Transforms/SimplifyCFG/sink-and-convert-switch.ll
@@ -0,0 +1,61 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
+; RUN: opt -S -passes='simplifycfg<sink-common-insts;switch-to-lookup>' < %s | FileCheck %s
+
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
+
+define void @pr104567(i8 %x, ptr %f) {
+; CHECK-LABEL: define void @pr104567(
+; CHECK-SAME: i8 [[X:%.*]], ptr [[F:%.*]]) {
+; CHECK-NEXT: [[START:.*:]]
+; CHECK-NEXT: [[Y:%.*]] = alloca [1 x i8], align 1
+; CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 1, ptr nonnull [[Y]])
+; CHECK-NEXT: switch i8 [[X]], label %[[DEFAULT_UNREACHABLE:.*]] [
+; CHECK-NEXT: i8 0, label %[[BB4:.*]]
+; CHECK-NEXT: i8 1, label %[[BB3:.*]]
+; CHECK-NEXT: i8 2, label %[[BB2:.*]]
+; CHECK-NEXT: ]
+; CHECK: [[DEFAULT_UNREACHABLE]]:
+; CHECK-NEXT: unreachable
+; CHECK: [[BB4]]:
+; CHECK-NEXT: store i8 4, ptr [[Y]], align 1
+; CHECK-NEXT: br label %[[BB5:.*]]
+; CHECK: [[BB3]]:
+; CHECK-NEXT: store i8 5, ptr [[Y]], align 1
+; CHECK-NEXT: br label %[[BB5]]
+; CHECK: [[BB2]]:
+; CHECK-NEXT: store i8 6, ptr [[Y]], align 1
+; CHECK-NEXT: br label %[[BB5]]
+; CHECK: [[BB5]]:
+; CHECK-NEXT: call void [[F]](ptr [[Y]])
+; CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 1, ptr nonnull [[Y]])
+; CHECK-NEXT: ret void
+;
+start:
+ %y = alloca [1 x i8], align 1
+ call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %y)
+ switch i8 %x, label %default.unreachable [
+ i8 0, label %bb4
+ i8 1, label %bb3
+ i8 2, label %bb2
+ ]
+
+default.unreachable:
+ unreachable
+
+bb4:
+ store i8 4, ptr %y, align 1
+ br label %bb5
+
+bb3:
+ store i8 5, ptr %y, align 1
+ br label %bb5
+
+bb2:
+ store i8 6, ptr %y, align 1
+ br label %bb5
+
+bb5:
+ call void %f(ptr %y)
+ call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %y)
+ ret void
+}
More information about the llvm-commits
mailing list