APInt with uint64_t comparison

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

APInt with uint64_t comparison

Paweł Bylica
Hi LLVM,

I have painfully found out that APInt comparison with uint64_t using methods like .ult() is done with the precision of the APInt instance. The uint64_t argument is usually silently truncated then. E.g. APInt{8, 1}.ult(256) is false.

I propose to change that and do the comparison with 64 bit precision. I think it is much more useful as APInts representing the value of a constant is often compared with the size of a type.

There are no unit tests for APInt comparisons. I've changed the implementation locally and haven't spot any regressions.

If the proposal is accepted I will send the patch for review and do self-hosted testing.

Cheers,
- Paweł

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: APInt with uint64_t comparison

Paweł Bylica
On Tue, Jun 23, 2015 at 1:27 PM Paweł Bylica <[hidden email]> wrote:
Hi LLVM,

I have painfully found out that APInt comparison with uint64_t using methods like .ult() is done with the precision of the APInt instance. The uint64_t argument is usually silently truncated then. E.g. APInt{8, 1}.ult(256) is false.

I propose to change that and do the comparison with 64 bit precision. I think it is much more useful as APInts representing the value of a constant is often compared with the size of a type.

There are no unit tests for APInt comparisons. I've changed the implementation locally and haven't spot any regressions.

I haven't found any issues in self-hosted check-all and test-suite.

If the proposal is accepted I will send the patch for review and do self-hosted testing.

Cheers,
- Paweł

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev