Skip to content

Improve codegen for ??= in Nullable Value Type scenarios #36548

@333fred

Description

@333fred

Because of concerns with the underlying code of TransformCompoundAssignmentLHS (#36443), we're not currently using BoundSpillSequences to lower ??= in the nullable value type case. We can improve codegen by using these after we're sure that the causes of #36443 are fixed.

Current codegen form:

var tmp = lhsRead.GetValueOrDefault()
lhsRead.HasValue ? tmp : { /* sequence */ tmp = loweredRight; transformedLhs = tmp; tmp }

Better form:

var tmp = lhsRead.GetValueOrDefault();
if (lhsRead.GetValueOrDefault())
{
	tmp = loweredRight;
	transformedLhs = tmp;
}
tmp

This better form needs a BoundSpillSequence.

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions