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

Zahira Ammarguellat via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 15 05:54:18 PDT 2024


================
@@ -794,8 +834,10 @@ ComplexPairTy ComplexExprEmitter::EmitBinMul(const BinOpInfo &Op) {
       ResR = Builder.CreateFSub(AC, BD, "mul_r");
       ResI = Builder.CreateFAdd(AD, BC, "mul_i");
 
-      if (Op.FPFeatures.getComplexRange() == LangOptions::CX_Limited ||
-          Op.FPFeatures.getComplexRange() == LangOptions::CX_Fortran)
+      if (Op.FPFeatures.getComplexRange() == LangOptions::CX_Basic ||
+          Op.FPFeatures.getComplexRange() == LangOptions::CX_Improved ||
+          Op.FPFeatures.getComplexRange() == LangOptions::CX_Promoted ||
+          CGF.getLangOpts().NoHonorInfs || CGF.getLangOpts().NoHonorNaNs)
----------------
zahiraam wrote:

This code is in `EmitBinMul` and your `godbolt` link has a `div` operation.
At any case the `complex-range` is **not** set when `-ffinite-math-only` is used on the command line. The function `applyFastMath` sets the range only when `ffast-math` or `fp-model` are used. With `CGF.getLangOpts().NoHonorInfs || CGF.getLangOpts().NoHonorNaNs` we would get the same behavior than `gcc` for a` mul` operation: algebraic  implementation with no `nan` testing.
If you don't want this condition  here. then `applyFastMath` needs to be called when `ffinite-math-only` is on the command line.
WDYT?

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


More information about the cfe-commits mailing list