[PATCH] Narrow ARRAY*_REF indexes to sizetype for gimple (PR tree-optimization/89223)
Jakub Jelinek
jakub@redhat.com
Fri Feb 8 11:58:00 GMT 2019
On Fri, Feb 08, 2019 at 12:47:08PM +0100, Richard Biener wrote:
> My worry is that while we know the IV i doesn't wrap we
> don't know the same for (sizetype)i in
>
> for (__int128 i = 0; i < n; ++i)
> a[i] = 0.;
First of all, for normal targets I think it is very rare that people use
__int128 array indexes (or long long on 32-bit targets).
I agree it can happen on weird targets more often.
> and thus vectorization doesn't work. Similar for
>
> void foo(long n, int *a)
> {
> for (long i = 0; i < n; ++i)
> a[i] = 1;
> }
Well, we should be able to improve the number of iterations analysis here
for the > sizetype ones, no valid array should have more than PTRDIFF_MAX
or SIZE_MAX-1 elements (well, all objects should have computable sizeof and
pointer subtraction needs to work, so it is even divided by the element type)
and thus we could derive some reasonable range for the loops with > sizetype
IVs where we use that.
Jakub
More information about the Gcc-patches
mailing list