[llvm-commits] [PATCH][APFloat] add APFloat::isDenormal()

Shuxin Yang shuxin.llvm at gmail.com
Wed Jan 2 10:45:29 PST 2013


Hi,

     The attached tiny patch is to add APFloat::isDenormal() to APFloat 
class.
Only the changes to APFloat.{cxx,h} are relevant, the rest are test to 
see if it works.

    As far as I can tell, a APFloat is a denormal if it satisfies 
following conditions:
   1. it is not zero/infinity/nan (i.e APFloat::isNormal() == ture)
   2. the exponent field take the minimal value
   3. the most-significant-bit of the mantissa bit is 0

   I think condition-3 implies 2). However, in my change I still test 
these three conditions.
The rationale is twofold: condition-2 is cheap to verify and testing 2) 
would likely yields
early-exist.

    The "test" is hard-coded in the InstCombineAddSub.cpp (this part is 
not going to be committed).
and the test is triggered by any *.ll having a fadd instruction.

    The "test" covers the tricky cases about 
single/double/quadruple-precision as well as Intel 80-bit
double-ext precision floating-point. I don't know how to test PPC FP. 
But I don't think it is necessary
to test PPC FP as APFloat is a arch-neutral representations of all these 
formats.

Thank you for code review!

Shuxin




-------------- next part --------------
A non-text attachment was scrubbed...
Name: diff.patch
Type: text/x-patch
Size: 3254 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130102/090e7d88/attachment.bin>


More information about the llvm-commits mailing list