mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
I am doing this separately from the actual change to eliminate the option to make it easier to review.
55 lines
2.0 KiB
Plaintext
55 lines
2.0 KiB
Plaintext
// 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: %5 = load i32, i32* %4
|
|
// CHECK-64: %8 = load i1, i1* %7
|
|
// CHECK-64: [[PAYLOAD:%.*]] = icmp eq i32 %5, 0
|
|
// CHECK-64: [[EXTRA:%.*]] = and i1 %8, [[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: %5 = load i32, i32* %4
|
|
// CHECK-64: %8 = load i1, i1* %7
|
|
// CHECK-64: [[PAYLOAD:%.*]] = icmp eq i32 %5, 1
|
|
// CHECK-64: [[EXTRA:%.*]] = and i1 %8, [[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
|
|
}
|