Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Clang][CodeGen] Promote in complex compound divassign #131453

Merged
merged 1 commit into from
Mar 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions clang/lib/CodeGen/CGExprComplex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1214,21 +1214,24 @@ EmitCompoundAssignLValue(const CompoundAssignOperator *E,
OpInfo.FPFeatures = E->getFPFeaturesInEffect(CGF.getLangOpts());
CodeGenFunction::CGFPOptionsRAII FPOptsRAII(CGF, OpInfo.FPFeatures);

const bool IsComplexDivisor = E->getOpcode() == BO_DivAssign &&
E->getRHS()->getType()->isAnyComplexType();

// Load the RHS and LHS operands.
// __block variables need to have the rhs evaluated first, plus this should
// improve codegen a little.
QualType PromotionTypeCR;
PromotionTypeCR = getPromotionType(E->getStoredFPFeaturesOrDefault(),
E->getComputationResultType(),
/*IsComplexDivisor=*/false);
PromotionTypeCR =
getPromotionType(E->getStoredFPFeaturesOrDefault(),
E->getComputationResultType(), IsComplexDivisor);
if (PromotionTypeCR.isNull())
PromotionTypeCR = E->getComputationResultType();
OpInfo.Ty = PromotionTypeCR;
QualType ComplexElementTy =
OpInfo.Ty->castAs<ComplexType>()->getElementType();
QualType PromotionTypeRHS =
getPromotionType(E->getStoredFPFeaturesOrDefault(),
E->getRHS()->getType(), /*IsComplexDivisor=*/false);
E->getRHS()->getType(), IsComplexDivisor);

// The RHS should have been converted to the computation type.
if (E->getRHS()->getType()->isRealFloatingType()) {
Expand Down Expand Up @@ -1258,7 +1261,7 @@ EmitCompoundAssignLValue(const CompoundAssignOperator *E,
SourceLocation Loc = E->getExprLoc();
QualType PromotionTypeLHS =
getPromotionType(E->getStoredFPFeaturesOrDefault(),
E->getComputationLHSType(), /*IsComplexDivisor=*/false);
E->getComputationLHSType(), IsComplexDivisor);
if (LHSTy->isAnyComplexType()) {
ComplexPairTy LHSVal = EmitLoadOfLValue(LHS, Loc);
if (!PromotionTypeLHS.isNull())
Expand Down
Loading
Loading