[PATCH] Avoid conversion to float when creating ConstantDataArray/ConstantDataVector

Nick Lewycky nicholas at mxc.ca
Sun Feb 8 14:39:35 PST 2015


Raoux, Thomas F wrote:
> Re-attaching the patch

+  static Constant *getFP(LLVMContext &Context, ArrayRef<uint32_t> Elts);
+  static Constant *getFP(LLVMContext &Context, ArrayRef<uint64_t> Elts);

Please give getFP its own group with its own doxygen comment describing 
the conversion, and maybe mention that float and double are defined in 
LangRef to be 32 and 64 bits respectively. It would be nice if this also 
handled half, fp128, x86_fp80 and ppc_fp128, to be orthogonal.

-            Elts.push_back(CFP->getValueAPF().convertToFloat());
+ 
Elts.push_back(CFP->getValueAPF().bitcastToAPInt().getZExtValue());

There's no actual zero-extension happening here, right? If not, I don't 
really see a clearly way to write it, maybe getLimitedValue?

The logic of the change and test look good to me.

Nick

>
> -----Original Message-----
> From: Raoux, Thomas F
> Sent: Thursday, February 05, 2015 10:23 AM
> To: 'llvm-commits at cs.uiuc.edu'
> Subject: [PATCH] Avoid conversion to float when creating ConstantDataArray/ConstantDataVector
>
> Ping. Could someone look at this patch about ConstantDataVector?
>
> -----Original Message-----
> From: Raoux, Thomas F
> Sent: Wednesday, January 28, 2015 8:15 AM
> To: 'llvm-commits at cs.uiuc.edu'
> Subject: [Patch] Avoid conversion to float when creating ConstantDataArray/ConstantDataVector
>
> Hi,
>
> Could someone review (and possibly commit) this patch related to ConstantDataArray/ConstantDataVector?
>
> This addresses a bug discussed in this thread: http://lists.cs.uiuc.edu/pipermail/llvmdev/2015-January/080575.html
>
> To avoid conversion to float and potential change of the constant I added new constructors for float types for ConstantDataArray/ConstantDataVector.
>
> Cheers,
> Thomas
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list