1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
// RUN: %target-swift-frontend %s -emit-ir | %FileCheck %s --check-prefix=CHECK-%target-ptrsize
// REQUIRES: CPU=i386 || CPU=x86_64
sil_stage canonical
import Builtin
enum ManyEmptyCases {
case A
case B
case C(Builtin.Int32)
}
// CHECK-LABEL-64: define{{( protected)?}} swiftcc i1 @select_enum_A(i64)
// CHECK-64: %2 = load i32, ptr %temp-coercion.coerced
// CHECK-64: %4 = load i1, ptr %3
// CHECK-64: [[PAYLOAD:%.*]] = icmp eq i32 %2, 0
// CHECK-64: [[EXTRA:%.*]] = and i1 %4, [[PAYLOAD]]
// CHECK-64: ret i1 [[EXTRA]]
// CHECK-LABEL-32: define{{( protected)?}} swiftcc i1 @select_enum_A(i32, i8) {{.*}}{
// CHECK-32: entry:
// CHECK-32: %2 = trunc i8 %1 to i1
// CHECK-32: %3 = icmp eq i32 %0, 0
// CHECK-32: %4 = and i1 %2, %3
// CHECK-32: ret i1 %4
sil @select_enum_A : $@convention(thin) (ManyEmptyCases) -> Builtin.Int1 {
entry(%0 : $ManyEmptyCases):
%4 = integer_literal $Builtin.Int1, -1 // user: %6
%5 = integer_literal $Builtin.Int1, 0 // user: %6
%6 = select_enum %0 : $ManyEmptyCases, case #ManyEmptyCases.A!enumelt: %4, default %5 : $Builtin.Int1
return %6 : $Builtin.Int1
}
// CHECK-LABEL-64: define{{( protected)?}} swiftcc i1 @select_enum_B(i64)
// CHECK-64: %2 = load i32, ptr %temp-coercion.coerced
// CHECK-64: %4 = load i1, ptr %3
// CHECK-64: [[PAYLOAD:%.*]] = icmp eq i32 %2, 1
// CHECK-64: [[EXTRA:%.*]] = and i1 %4, [[PAYLOAD]]
// CHECK-64: ret i1 [[EXTRA]]
// CHECK-LABEL-32: define{{( protected)?}} swiftcc i1 @select_enum_A(i32, i8) {{.*}}{
// CHECK-32: entry:
// CHECK-32: %2 = trunc i8 %1 to i1
// CHECK-32: %3 = icmp eq i32 %0, 1
// CHECK-32: %4 = and i1 %2, %3
// CHECK-32: ret i1 %4
sil @select_enum_B : $@convention(thin) (ManyEmptyCases) -> Builtin.Int1 {
entry(%0 : $ManyEmptyCases):
%4 = integer_literal $Builtin.Int1, -1 // user: %6
%5 = integer_literal $Builtin.Int1, 0 // user: %6
%6 = select_enum %0 : $ManyEmptyCases, case #ManyEmptyCases.B!enumelt: %4, default %5 : $Builtin.Int1
return %6 : $Builtin.Int1
}
|