[PATCH] D149587: InstSimplify: Simplifications for ldexp

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 11 06:54:42 PDT 2023


arsenm added inline comments.


================
Comment at: llvm/lib/Analysis/InstructionSimplify.cpp:6106
+  if (C && C->isNaN())
+    return ConstantFP::get(Op0->getType(), C->makeQuiet());
+
----------------
kpn wrote:
> arsenm wrote:
> > foad wrote:
> > > Why is this not strictfp-safe?
> > > 
> > > Maybe I just need a good description of what strictfp implies. The description in the langref mentions rounding mode, status flags and trapping, but says nothing about quieting NaNs.
> > A signaling nan is supposed to raise an exception which quieting it would hide.
> > 
> > The [[https://llvm.org/docs/LangRef.html#floating-point-environment  | LangRef]] states signaling nans may not be quieted by non-constrained operations and constrained should handle them properly
> With "maytrap' we are allowed to remove exceptions. That should make quieting an sNaN safe, no? Also, are callers checking for the default fp environment? That should behave the same as non-constrained operations.
I just remembered this also has the problem that the constrained operations aren't fully expressive enough. "Default FP environment" doesn't cover denormal flushing or other target dependent modes. 


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D149587/new/

https://reviews.llvm.org/D149587



More information about the llvm-commits mailing list