[PATCH] Ocaml binding update for fast math flags optimisation

J. Charles N. MBIADA jcharles.nmbiada at gmail.com
Mon Jul 14 12:57:19 PDT 2014


After the last patch I found that, parts code in my project where I suppressed flags from an instruction did not work as expected. This is the patch to resolve that.

http://reviews.llvm.org/D4423

Files:
  lib/IR/Core.cpp

Index: lib/IR/Core.cpp
===================================================================
--- lib/IR/Core.cpp
+++ lib/IR/Core.cpp
@@ -592,6 +592,19 @@
 }
 
 void LLVMSetFastMathFlags(LLVMValueRef Inst, int Flags){
+  if (0 == Flags){
+    FastMathFlags fmf =
+      (unwrap<Instruction>(Inst)->getFastMathFlags());
+    fmf.clear();
+    unwrap<Instruction>(Inst)->setFastMathFlags(fmf);
+    unwrap<Instruction>(Inst)->setHasUnsafeAlgebra(false);
+    unwrap<Instruction>(Inst)->setHasNoNaNs(false);
+    unwrap<Instruction>(Inst)->setHasNoInfs(false);
+    unwrap<Instruction>(Inst)->setHasNoSignedZeros(false);
+    unwrap<Instruction>(Inst)->setHasAllowReciprocal(false);
+    return;
+  }
+
   if (Flags & FastMathFlags::UnsafeAlgebra)
     unwrap<Instruction>(Inst)->setHasUnsafeAlgebra(true);
   if (Flags & FastMathFlags::NoNaNs)
@@ -602,12 +615,6 @@
     unwrap<Instruction>(Inst)->setHasNoSignedZeros(true);
   if (Flags & FastMathFlags::AllowReciprocal)
     unwrap<Instruction>(Inst)->setHasAllowReciprocal(true);
-  if (0 == Flags){
-    FastMathFlags fmf =
-      (unwrap<Instruction>(Inst)->getFastMathFlags());
-    fmf.clear();
-    unwrap<Instruction>(Inst)->setFastMathFlags(fmf);
-  }
 }
 
 int LLVMCountFastMathFlags(LLVMValueRef Inst){
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4423.11402.patch
Type: text/x-patch
Size: 1259 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140714/3b1df47d/attachment.bin>


More information about the llvm-commits mailing list