fhahn added reviewers: arphaman, GorNishanov, hfinkel, fhahn.
fhahn added a comment.

Looks good to me, with some nits. However it seems that we do not use the fast 
math flags anywhere else in Clang codegen, so it would be good to clarify if it 
is OK to use it here.



================
Comment at: lib/CodeGen/CGExprComplex.cpp:768
+
     // If we have a complex operand on the RHS, we delegate to a libcall to
     // handle all of the complexities and minimize underflow/overflow cases.
----------------
Maybe we should update the comment that we do a similar simplification for 
floats with fast math enabled as for integers?


================
Comment at: lib/CodeGen/CGExprComplex.cpp:773
     // supported imaginary types in addition to complex types.
-    if (RHSi) {
+    if (RHSi && !FMF.isFast()) {
       BinOpInfo LibCallOp = Op;
----------------
Would the following structure be slightly easier to read?

if (RHSi) {
  if (FMF.isFast()) { simplify } else {libcall}
}


================
Comment at: lib/CodeGen/CGExprComplex.cpp:800
+      // (a+ib) / (c+id) = ((ac+bd)/(cc+dd)) + i((bc-ad)/(cc+dd))
+      llvm::Value *AC = Builder.CreateFMul(LHSr, RHSr); // a*c
+      llvm::Value *BD = Builder.CreateFMul(LHSi, RHSi); // b*d
----------------
This is basically the same as the simplification for integers, unfortunate that 
we have to duplicate it (because of different instructions).


https://reviews.llvm.org/D40299



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to