[llvm-commits] [llvm] r125393 - in /llvm/trunk: lib/VMCore/ConstantFold.cpp test/Transforms/InstCombine/bitcast-vec-uniform.ll test/Transforms/InstCombine/fold-vector-select.ll
Duncan Sands
baldrick at free.fr
Thu Feb 17 00:16:06 PST 2011
Hi Nadav,
> I attached a revised patch which supports getAllOnesValue on FP values. I added minor changes to APFloat as well as new tests.
> --- include/llvm/ADT/APFloat.h (revision 125681)
> +++ include/llvm/ADT/APFloat.h (working copy)
> @@ -246,6 +246,13 @@
> static APFloat getSmallestNormalized(const fltSemantics &Sem,
> bool Negative = false);
>
> + /// getAllOnesValue - Returns a float which is bitcasted from
> + /// an all one value int
I don't think you should mention bitcasting here. How about:
Returns a float with every bit set to one.
> --- lib/VMCore/Constants.cpp (revision 125681)
> +++ lib/VMCore/Constants.cpp (working copy)
> @@ -93,7 +93,26 @@
> if (const IntegerType *ITy = dyn_cast<IntegerType>(Ty))
> return ConstantInt::get(Ty->getContext(),
> APInt::getAllOnesValue(ITy->getBitWidth()));
> -
> +
> + if (Ty->isFloatingPointTy()) {
> + APFloat FL(0.0f);
> + switch (Ty->getTypeID()) {
You can get the bitwidth using Ty->getPrimitiveSizeInBits(). Thus you only
have to worry about setting the IEEE flag right. So the switch etc can be
turned into something like this:
APFloat FL = APFloat::getAllOnesValue(Ty->getPrimitiveSizeInBits(),
Ty->isPPC_FP128Ty());
Ciao, Duncan.
More information about the llvm-commits
mailing list