Issue 120630
Summary [DirectX] Transform fast math flags to LLVM 3.7 for bitcode writer
Labels backend:DirectX
Assignees
Reporter llvm-beanz
    The DXIL bitcode writer is currently encoding modern LLVM fast math flags instead of LLVM 3.7's equivalent.  The patch below is probably a starting point, but is likely not everything that needs to change to address this problem.

```diff
diff --git a/llvm/lib/Target/DirectX/DXILWriter/DXILBitcodeWriter.cpp b/llvm/lib/Target/DirectX/DXILWriter/DXILBitcodeWriter.cpp
index 45aadac86194..4ea31dde3e00 100644
--- a/llvm/lib/Target/DirectX/DXILWriter/DXILBitcodeWriter.cpp
+++ b/llvm/lib/Target/DirectX/DXILWriter/DXILBitcodeWriter.cpp
@@ -749,20 +749,14 @@ uint64_t DXILBitcodeWriter::getOptimizationFlags(const Value *V) {
     if (PEO->isExact())
       Flags |= 1 << bitc::PEO_EXACT;
   } else if (const auto *FPMO = dyn_cast<FPMathOperator>(V)) {
-    if (FPMO->hasAllowReassoc())
-      Flags |= bitc::AllowReassoc;
+    if (FPMO->hasAllowReassoc() || FPMO->hasAllowContract())
+      Flags |= bitc::UnsafeAlgebra;
     if (FPMO->hasNoNaNs())
       Flags |= bitc::NoNaNs;
     if (FPMO->hasNoInfs())
       Flags |= bitc::NoInfs;
 if (FPMO->hasNoSignedZeros())
       Flags |= bitc::NoSignedZeros;
- if (FPMO->hasAllowReciprocal())
-      Flags |= bitc::AllowReciprocal;
- if (FPMO->hasAllowContract())
-      Flags |= bitc::AllowContract;
-    if (FPMO->hasApproxFunc())
-      Flags |= bitc::ApproxFunc;
   }

   return Flags;
 
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to