[PATCH] D112117: [LV] Drop FP flags from instructions that need predication

Diego Caballero via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 19 18:53:28 PDT 2021


dcaballe created this revision.
dcaballe added reviewers: lebedev.ri, fhahn, rogfer01, Ayal, spatel, dmgreen.
Herald added a subscriber: hiraditya.
dcaballe requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

See D111846 <https://reviews.llvm.org/D111846> for more context. LV propagates FP flags in instructions that are
originally guarded by a condition and its respective control flow. It may happen that
the FP flags are only valid when the condition and control flow is in place. When the code
is vectorized and the control flow within the loop is linearized, the FP flags may no
longer hold and lead to a poison value if they are propagated.

TODO: Determine which FP flags should be dropped. The obvious ones are `HasNoNaNs`,
`HasNoInfs` and `HasNoSignedZeros`. I'm not sure if not dropping any of remaining would
lead to correctness issues or dropping them would actually be problematic.

TODO: Find proper tests that show that propagating the FP flags would be incorrect.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112117

Files:
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp


Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -3049,6 +3049,11 @@
   }
   if (isa<PossiblyExactOperator>(NewInst))
     NewInst->setIsExact(false);
+  if (isa<FPMathOperator>(NewInst)) {
+    NewInst->setHasNoNaNs(false);
+    NewInst->setHasNoInfs(false);
+    NewInst->setHasNoSignedZeros(false);
+  }
 }
 
 void InnerLoopVectorizer::scalarizeInstruction(Instruction *Instr,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112117.380841.patch
Type: text/x-patch
Size: 561 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211020/b29b8c76/attachment.bin>


More information about the llvm-commits mailing list