Skip to content

Commit 36ebd22

Browse files
committed
---
yaml --- r: 347375 b: refs/heads/master c: 2b00251 h: refs/heads/master i: 347373: a379eb3 347371: dda1eb2 347367: 06be74d 347359: 4289149
1 parent 9beb466 commit 36ebd22

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: a3c6d875e9d645809756565f5ca581299f322e5f
2+
refs/heads/master: 2b00251b89380db07de4b86a242962e64cba87a6
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/lib/IRGen/GenEnum.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1879,11 +1879,15 @@ namespace {
18791879
// more no-payload case than extra inhabitants in the payload. This could
18801880
// be slightly generalized to cases where there's multiple tag bits and
18811881
// exactly one no-payload case in the highest used tag value.
1882+
unsigned extraInhabitantCount = getFixedExtraInhabitantCount(IGF.IGM);
18821883
if (!tagBits ||
1883-
ElementsWithNoPayload.size() != getFixedExtraInhabitantCount(IGF.IGM)+1)
1884-
payloadResult = payload.emitCompare(IGF,
1885-
ti.getFixedExtraInhabitantMask(IGF.IGM),
1886-
payloadTag);
1884+
ElementsWithNoPayload.size() != extraInhabitantCount + 1) {
1885+
payloadResult = payload.emitCompare(
1886+
IGF,
1887+
extraInhabitantCount == 0 ? APInt::getAllOnesValue(PayloadBitCount)
1888+
: ti.getFixedExtraInhabitantMask(IGF.IGM),
1889+
payloadTag);
1890+
}
18871891

18881892
// If any tag bits are present, they must match.
18891893
llvm::Value *tagResult = nullptr;

trunk/test/IRGen/enum.sil

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,24 @@ enum SinglePayloadNoXI2 {
474474
case u
475475
}
476476

477+
// CHECK-32: define{{( dllexport)?}}{{( protected)?}} swiftcc i1 @select_enum([[WORD:i32]], i8)
478+
// CHECK-64: define{{( dllexport)?}}{{( protected)?}} swiftcc i1 @select_enum([[WORD:i64]], i8)
479+
// CHECK: entry:
480+
// CHECK: [[TAG:%.*]] = trunc i8 %1 to i1
481+
// CHECK: [[PAYLOAD:%.*]] = icmp eq [[WORD]] %0, 1
482+
// CHECK: [[MATCHES:%.*]] = and i1 [[TAG]], [[PAYLOAD]]
483+
// CHECK: [[RES:%.*]] = select i1 [[MATCHES]], i1 false, i1 true
484+
// CHECK: ret i1 [[RES]]
485+
// CHECK: }
486+
487+
sil @select_enum : $@convention(method) (SinglePayloadNoXI2) -> Builtin.Int1 {
488+
bb0(%0 : $SinglePayloadNoXI2):
489+
%2 = integer_literal $Builtin.Int1, 0
490+
%3 = integer_literal $Builtin.Int1, -1
491+
%4 = select_enum %0 : $SinglePayloadNoXI2, case #SinglePayloadNoXI2.z!enumelt: %2, default %3 : $Builtin.Int1
492+
return %4 : $Builtin.Int1
493+
}
494+
477495
// CHECK-64: define{{( dllexport)?}}{{( protected)?}} swiftcc void @single_payload_no_xi_switch([[WORD:i64]], i8) {{.*}} {
478496
// CHECK-32: define{{( dllexport)?}}{{( protected)?}} swiftcc void @single_payload_no_xi_switch([[WORD:i32]], i8) {{.*}} {
479497
sil @single_payload_no_xi_switch : $@convention(thin) (SinglePayloadNoXI2) -> () {

0 commit comments

Comments
 (0)