[llvm-commits] [llvm] r68768 - /llvm/trunk/include/llvm/Support/IRBuilder.h

Jeffrey Yasskin jyasskin at google.com
Thu Apr 9 23:08:49 PDT 2009


On Thu, Apr 9, 2009 at 10:35 PM, Chris Lattner <clattner at apple.com> wrote:
> On Apr 9, 2009, at 10:30 PM, Nick Lewycky wrote:
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=68768&view=rev
>> Log:
>> Add utility function to IRBuilder that takes the difference between two
>> pointers, taking into account the size of the pointed-to object.
>> Patch by Jeffrey Yasskin!
>
> looks good to me.  Incidentally, clang and llvm-gcc specialize the case when
> the element size is a power of two into a signed right shift.  This is legal
> because C only allows pointer subtraction between elements in the same
> array, which means the division must be "exact".  In this case, SRA x, c is
> the same as sdiv x, 2^c.  I don't know if you care about this case though.

It would be nice to optimize that, or provide enough information to
let a downstream pass optimize it, but I don't know a reliable way to
do it in the IRBuilder, which doesn't have target data. Is there a
way?




More information about the llvm-commits mailing list