[llvm-commits] [pr12251][patch] Use i1* for boolean loads and stores
Rafael EspĂndola
rafael.espindola at gmail.com
Tue Mar 13 11:41:46 PDT 2012
In the testcase of pr12251 we use a i8* for loading a boolean value:
%3 = load i8* %2
%4 = trunc i8 %3 to i
The problem then is that LLVM has no way of knowing that %3 can only
be 0 or 1. A C file using uint8_t would have compiled to the same IL.
It would be nice to have a general way of telling LLVM that a value is
known to be in a range, but for the specific cases of booleans we can
do better by just using a more restrictive type. This patch changes
clang to use i1 pointers for doing the loads and stores. This changes
the generated code from
movb (%rdi), %al
andb $1, %al
ret
to just
movb (%rdi), %al
ret
I think the idea can be extended for systems that use 32 bit booleans.
We would just have to be careful with endianess. I got the idea from
http://llvm.org/bugs/show_bug.cgi?id=8730#c3.
Is this patch OK?
Cheers,
Rafael
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr12251.patch
Type: application/octet-stream
Size: 14451 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120313/8c8da5af/attachment.obj>
More information about the llvm-commits
mailing list