File tree Expand file tree Collapse file tree 2 files changed +26
-4
lines changed
Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Original file line number Diff line number Diff 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 ;
Original file line number Diff line number Diff line change @@ -474,6 +474,24 @@ enum SinglePayloadNoXI2 {
474474 case u
475475}
476476
477+ // CHECK-32: define swiftcc i1 @select_enum([[WORD:i32]], i8)
478+ // CHECK-64: define 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) {{.*}} {
479497sil @single_payload_no_xi_switch : $@convention(thin) (SinglePayloadNoXI2) -> () {
You can’t perform that action at this time.
0 commit comments