[clang] [CLANG] Full support of complex multiplication and division. (PR #81514)

Joshua Cranmer via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 29 13:21:30 PST 2024


================
@@ -982,13 +1022,18 @@ ComplexPairTy ComplexExprEmitter::EmitBinDiv(const BinOpInfo &Op) {
     llvm::Value *OrigLHSi = LHSi;
     if (!LHSi)
       LHSi = llvm::Constant::getNullValue(RHSi->getType());
-    if (Op.FPFeatures.getComplexRange() == LangOptions::CX_Fortran)
+    QualType ComplexElementTy = Op.Ty->castAs<ComplexType>()->getElementType();
+    const BuiltinType *BT = ComplexElementTy->getAs<BuiltinType>();
+    if (Op.FPFeatures.getComplexRange() == LangOptions::CX_Improved ||
+        (Op.FPFeatures.getComplexRange() == LangOptions::CX_Promoted &&
+         BT->getKind() == BuiltinType::Kind::LongDouble))
----------------
jcranmer-intel wrote:

This isn't going to do the right thing for `_Complex __float128` I believe. Or `_Complex double` in the case where `long double` is binary64, I'm pretty sure, since that would promote it to itself and then do basic.

https://github.com/llvm/llvm-project/pull/81514


More information about the cfe-commits mailing list