[PATCH] D30184: [IR] Add a Instruction::dropPoisonGeneratingFlags helper

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 21 14:16:39 PST 2017


efriedma added inline comments.


================
Comment at: lib/IR/Instruction.cpp:126
+void Instruction::dropPoisonGeneratingFlags() {
+  switch (getOpcode()) {
+  case Instruction::Add:
----------------
majnemer wrote:
> sanjoy wrote:
> > majnemer wrote:
> > > What about the FP operations?
> > None of the floating point operations are specified to generate poison.  Are you suggesting that we interpret flags like `nsz` like we interpret `nsw`?  If so, I think that's viable, but the docs need to change first.  Personally I'd say that kind of stuff is blocked on integrating the new poison semantics into LLVM.
> Considering that we perform reassociation type optimizations based off those fast math flags, I think they are already defacto poison whether they want to be or not ;)
> 
> However, we shouldn't gate this change on that.
> Considering that we perform reassociation type optimizations based off those fast math flags, I think they are already defacto poison whether they want to be or not ;)

A "fast" fadd returns an arbitrary value each time it's executed, but that's not the same thing as poison.  (There isn't any optimization reason to introduce undefined behavior into floating-point math, as far as I know.)


https://reviews.llvm.org/D30184





More information about the llvm-commits mailing list