[LLVMdev] MemoryBuffer

Gordon Henriksen gordonhenriksen at me.com
Thu Sep 24 16:38:07 PDT 2009


On 2009-09-24, at 18:56, OvermindDL1 wrote:

> Out of curiosity, what code in Clang is optimized by doing a pointer  
> derefence then compare to 0, rather then just comparing two points  
> directly?  Does not seem that efficient when laid out like that,  
> which is why I am curious what code actually is helped by that  
> pattern?


Consider parsing an integer:

// With NUL termination.
while ('0' <= *p && *p <= '9')
	n = n * 10 + (*p - '0');

// Without.
while (p != e && '0' <= *p && *p <= '9')
	n = n * 10 + (*p - '0');

— Gordon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090924/818f64d6/attachment.html>


More information about the llvm-dev mailing list