; 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_OFFSET:%.*]] = add nsw i8 [[X]], 4
; CHECK-NEXT: store i8 [[SWITCH_OFFSET]], ptr [[Y]], align 1
; 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
}