[LLVMdev] Fwd: Re: NaNs and Infinities
Javier Martinez
javier at jmartinez.org
Tue Apr 20 10:28:29 PDT 2010
I forgot to forward to the rest of the list...
-------- Original Message --------
Subject: Re: [LLVMdev] NaNs and Infinities
Date: Mon, 19 Apr 2010 23:41:43 -0700
From: Javier Martinez <javier at jmartinez.org>
To: lost <lostfreeman at gmail.com>
Hi,
If it's an immediate you can cast the SDValue to a ConstantFP and use
the isNaN() or isInfinity() member functions (see below). For non
immediates you can use bitcasting to convert the float to an integer. If
bits 0-22 are 0 and bits 23-30 are 1 it's infinity; if bits 0-22 are not
0 and bits 23-30 are 1 it's NaN. Others can probably give you a answer
and if not at least you have mine.
ConstantFM *CFP = dyn_cast<ConstantFP>(myValue);
if (CFP != NULL) {
CFP->getValueAPF().isNaN();
CFP->getValueAPF().isInfinity();
} else {
// Bitcast to an integer at test bits
}
Thanks,
Javier
On 4/19/2010 3:19 AM, lost wrote:
> Hello!
>
> How can I test if floating-point value is NaN or positive/negative
infinity?
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
More information about the llvm-dev
mailing list