[LLVMdev] instruction combiner patch
Andrew Lenharth
andrewl at lenharth.org
Wed Jun 7 05:29:29 PDT 2006
On Wed, 2006-06-07 at 03:17 -0400, Nick Lewycky wrote:
> I once wrote:
>
> > 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.
>
> That patch had to be removed as it broke SPEC. I've since updated the
> patch, and am ready to break spec again. ;-) This patch adds constant
> folding of multidimensional arrays even when the index to those arrays
> is a single value, ala:
>
> int x[2][2] = { {40, 41}, {42, 43} };
> int *y = x;
> return y[2];
>
> becomes:
>
> return 42;
>
> Similarly, it also generates undef on out of range arrays, but only if
> it's out of the range of the whole multi-dimensional array this time.
What would it do for:
struct foo {
int x;
int y[0];
};
...
struct foo* f = ...;
f->y[10];
This type of things is quite common and making it undef will break
things. I don't think the undef part can work safely.
Andrew
More information about the llvm-dev
mailing list