[LLVMdev] Representing -ffast-math at the IR level

Renato Golin rengolin at systemcall.org
Mon Apr 16 05:16:38 PDT 2012


Hi Duncan,

I like the changes to IRBuilder and how the operator can't change it.
Looks a lot safer (mistake-wise) and more convenient.

This function won't to remove a previously set tag, which could be
used by optimisations or inlining.

+  Instruction *AddFPMathTag(Instruction *I, MDNode *FPMathTag) const {
+    if (!FPMathTag)
+      FPMathTag = DefaultFPMathTag;
+    if (FPMathTag)
+      I->setMetadata(LLVMContext::MD_fpmath, FPMathTag);
+    return I;
+  }

If you want to keep it as only Add, then make FPMathTag = 0 so that
you can easily add the default by just calling AddFPMathTag(instr);

But I'd add a ClearFPMathTag function for optimisations/inlining. Maybe later.

Also, would be good to make sure the instruction is, in fact, a
floating point operation. Either via restricting the type or asserting
on it.

-- 
cheers,
--renato

http://systemcall.org/



More information about the llvm-dev mailing list