1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes=simplifycfg -simplifycfg-require-and-preserve-domtree=1 < %s | FileCheck %s
4 define i32 @test1(i32 %x) nounwind {
6 ; CHECK-NEXT: common.ret:
7 ; CHECK-NEXT: [[I:%.*]] = shl i32 [[X:%.*]], 1
8 ; CHECK-NEXT: [[COND:%.*]] = icmp eq i32 [[I]], 24
9 ; CHECK-NEXT: [[DOT:%.*]] = select i1 [[COND]], i32 5, i32 0
10 ; CHECK-NEXT: ret i32 [[DOT]]
13 switch i32 %i, label %a [
27 define i32 @test2(i32 %x) nounwind {
28 ; CHECK-LABEL: @test2(
30 ; CHECK-NEXT: ret i32 0
33 switch i32 %i, label %a [
46 ; We're sign extending an 8-bit value.
47 ; The switch condition must be in the range [-128, 127], so any cases outside of that range must be dead.
49 define i1 @repeated_signbits(i8 %condition) {
50 ; CHECK-LABEL: @repeated_signbits(
52 ; CHECK-NEXT: [[SEXT:%.*]] = sext i8 [[CONDITION:%.*]] to i32
53 ; CHECK-NEXT: switch i32 [[SEXT]], label [[DEFAULT:%.*]] [
54 ; CHECK-NEXT: i32 0, label [[COMMON_RET:%.*]]
55 ; CHECK-NEXT: i32 127, label [[COMMON_RET]]
56 ; CHECK-NEXT: i32 -128, label [[COMMON_RET]]
57 ; CHECK-NEXT: i32 -1, label [[COMMON_RET]]
60 ; CHECK-NEXT: [[COMMON_RET_OP:%.*]] = phi i1 [ false, [[DEFAULT]] ], [ true, [[ENTRY:%.*]] ], [ true, [[ENTRY]] ], [ true, [[ENTRY]] ], [ true, [[ENTRY]] ]
61 ; CHECK-NEXT: ret i1 [[COMMON_RET_OP]]
63 ; CHECK-NEXT: br label [[COMMON_RET]]
66 %sext = sext i8 %condition to i32
67 switch i32 %sext, label %default [
68 i32 -2147483648, label %a
75 i32 2147483647, label %a