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

Joshua Cranmer via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 8 11:43:40 PST 2024


================
@@ -982,13 +1024,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::Double))
----------------
jcranmer-intel wrote:

I still don't think this is the right way to do this logic. It's probably better to have a local effective complex range kind variable, and if promoted is requested but can't be done, have it swap it to improved.

(This will definitely break down for decimal floats/hexfloats!)

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


More information about the cfe-commits mailing list