1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 11:38:21 +02:00

Fixed some nullable splat cases

This commit is contained in:
Brian Fiete 2025-05-19 17:57:45 +02:00
parent c889877443
commit 192c9d8f33
2 changed files with 8 additions and 1 deletions

View file

@ -14159,6 +14159,8 @@ BfIRValue BfModule::ExtractValue(BfTypedValue typedValue, int dataIdx)
auto addrVal = mBfIRBuilder->CreateInBoundsGEP(typedValue.mValue, 0, dataIdx); auto addrVal = mBfIRBuilder->CreateInBoundsGEP(typedValue.mValue, 0, dataIdx);
return mBfIRBuilder->CreateAlignedLoad(addrVal, typedValue.mType->mAlign); return mBfIRBuilder->CreateAlignedLoad(addrVal, typedValue.mType->mAlign);
} }
if (typedValue.IsSplat())
typedValue = LoadOrAggregateValue(typedValue);
return mBfIRBuilder->CreateExtractValue(typedValue.mValue, dataIdx); return mBfIRBuilder->CreateExtractValue(typedValue.mValue, dataIdx);
} }

View file

@ -1519,10 +1519,15 @@ BfLocalVariable* BfModule::HandleVariableDeclaration(BfVariableDeclaration* varD
if (!resolvedType->IsNullable()) if (!resolvedType->IsNullable())
{ {
if (initValue.IsAddr()) if (initValue.IsAddr())
{
initValue = BfTypedValue(mBfIRBuilder->CreateInBoundsGEP(initValue.mValue, 0, 1), initValue.mType->GetUnderlyingType(), true); initValue = BfTypedValue(mBfIRBuilder->CreateInBoundsGEP(initValue.mValue, 0, 1), initValue.mType->GetUnderlyingType(), true);
}
else else
{
initValue = LoadOrAggregateValue(initValue);
initValue = BfTypedValue(mBfIRBuilder->CreateExtractValue(initValue.mValue, 1), initValue.mType->GetUnderlyingType()); initValue = BfTypedValue(mBfIRBuilder->CreateExtractValue(initValue.mValue, 1), initValue.mType->GetUnderlyingType());
} }
}
if ((initValue) && (!initValue.mType->IsValuelessType())) if ((initValue) && (!initValue.mType->IsValuelessType()))
{ {
@ -1600,7 +1605,7 @@ BfLocalVariable* BfModule::HandleVariableDeclaration(BfVariableDeclaration* varD
{ {
auto nullableElementType = initValue.mType->GetUnderlyingType(); auto nullableElementType = initValue.mType->GetUnderlyingType();
auto boolType = GetPrimitiveType(BfTypeCode_Boolean); auto boolType = GetPrimitiveType(BfTypeCode_Boolean);
initValue = LoadValue(initValue); initValue = LoadOrAggregateValue(initValue);
exprEvaluator->mResult = BfTypedValue(mBfIRBuilder->CreateExtractValue(initValue.mValue, nullableElementType->IsValuelessType() ? 1 : 2), boolType); exprEvaluator->mResult = BfTypedValue(mBfIRBuilder->CreateExtractValue(initValue.mValue, nullableElementType->IsValuelessType() ? 1 : 2), boolType);
handledExprBoolResult = true; handledExprBoolResult = true;
if (!nullableElementType->IsValuelessType()) if (!nullableElementType->IsValuelessType())