Nick Lewycky nicholas at mxc.ca
Wed May 10 10:30:09 PDT 2006

Nick Lewycky wrote:
> I tested it with "opt -sccp". I should've included a properly runnable
> example the first time. Sorry. At least, running "opt -load-vn -gcse"
> does not convert foo[0] into "102".

Further testing shows that the SCCP optimization will do handle it, and
so will the instruction combiner.

Chris Lattner wrote:
>>I'd suggest fixing this in the instcombine pass.  This isn't something
>>that the 'conditionalness' of SCCP adds value for, so doing it in a
>>simpler place is better.  If you have any questions about extending
>>instcombine (or anything else), please ask. :)

I've patched the instruction combiner to return UndefValue when the
index is constant and known to be out of range for either an ArrayType
or PackedType.

Patch attached.

Nick Lewycky
-------------- next part --------------
A non-text attachment was scrubbed...
Name: invalidindexundef.patch
Type: text/x-patch
Size: 1784 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20060510/a748ea21/attachment.bin>

More information about the llvm-dev mailing list