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

Hal Finkel hfinkel at anl.gov
Wed Jan 2 12:28:13 PST 2013


----- Original Message -----
> From: "Shuxin Yang" <shuxin.llvm at gmail.com>
> To: "l >> Commit Messages and Patches for LLVM" <llvm-commits at cs.uiuc.edu>
> Sent: Wednesday, January 2, 2013 12:45:29 PM
> Subject: [llvm-commits] [PATCH][APFloat] add APFloat::isDenormal()
> 
> 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.

I've cc'd Ulrich Weigand (who has most-recently worked on PPC FP128 support). I agree that testing PPC FP here can be omitted for now. For one thing, what the function should do may depend on how it is going to be used. PPC FP is really the sum of two doubles, but we currently approximate it (in the same way as gcc does) as one larger IEEE-like number.

 -Hal 

> 
> Thank you for code review!
> 
> Shuxin
> 
> 
> 
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> 

-- 
Hal Finkel
Postdoctoral Appointee
Leadership Computing Facility
Argonne National Laboratory



More information about the llvm-commits mailing list