[LLVMdev] RFC: new intrinsic llvm.memcmp?
bagel99 at gmail.com
Fri Aug 20 13:03:55 PDT 2010
I propose a new intrinsic "llvm.memcmp" that compares a block of memory
for equality (a subset of the libc behavior). Backends are free to use the
alignment to optimize using wider than byte operations. Since the result is
only equal/not-equal, byte order is not important.
For languages that support array compares, this would be very useful.
declare i1 @llvm.memcmp(i8* <arg1>, i8* <arg2>, i32 <len>, i32 <align>)
declare i1 @llvm.memcmp(i8* <arg1>, i8* <arg2>, i64 <len>, i32 <align>)
The 'llvm.memcmp.*' intrinsic compares a two blocks of memory for equality,
returning true if they are equal.
The first two arguments are pointers to the memory to be compared.
The third argument is an integer argument specifying the number of bytes to
compare, the fourth argument is the alignment of the two memory locations
If the call to this intrinsic has an alignment value that is not 0 or 1,
then the caller guarantees that both source pointers are aligned to that boundary.
More information about the llvm-dev