[PATCH] D39289: [SelectionDAG] Support 'bit preserving' floating points bitcasts on computeKnownBits/ComputeNumSignBits

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 26 06:57:33 PDT 2017


spatel added subscribers: escha, scanon.
spatel added inline comments.


================
Comment at: lib/CodeGen/SelectionDAG/SelectionDAG.cpp:2233
+    if (!(SubVT.isInteger() ||
+          (SubVT.isFloatingPoint() && TLI->hasBitPreservingFPLogic(SubVT))))
       break;
----------------
RKSimon wrote:
> efriedma wrote:
> > Not sure why you're checking hasBitPreservingFPLogic; from its documentation, it specifically applies to the behavior of FABS/FNEG.  BITCAST should always preserve all bits.
> @spatel might be able to give more details but I understood that hasBitPreservingFPLogic's scope was to cover all bit operations on floating point data? The FABS/FNEG are just explicitly mentioned as they're the typical uses of signbit masking/XORing.
> 
> I'm happy to simplify this if you think it safe.
FABS/FNEG were the motivation for the hook (D19391), but it could apply to something other than that, so I should improve that comment.

I don't know anything about the targets that inspired the hook, so I'd feel safer keeping the check. (cc @escha @scanon 
 ). 

Bitcast works "as if the value was stored to memory with one type and loaded from the same address with the other type." That doesn't imply that bits must be preserved? Eg, I could imagine something like any NAN bit pattern getting set to a fixed NAN value by the hardware.


Repository:
  rL LLVM

https://reviews.llvm.org/D39289





More information about the llvm-commits mailing list