https://gcc.gnu.org/bugzilla/show_bug.cgi?id=19792

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
I think for foo the "solution" is to only consider indices with well-defined
behavior, that is, for size_lookup[] indices in [0,257] which means we
should be safely able to truncate the index to unsigned char (for the
purpose of analysis only!).

Note we're not value-numbering (int) t the same as t but even
size_lookup[(short) t] should result in the same value to be loaded
unless undefined behavior is invoked.

Of course extern unsigned char size_lookup[257]; might be considered
extern unsigned char size_lookup[]; for QOI reasons and existing broken
code, so...  but just change the testcase to non-extern size_lookup.

The solution might ly in value-numbering which could, when value-numbering
the two loads lookup (and insert!) VNs of (shortest-allowed-type)index.
The danger is of course that the shortest-allowed-type might differ
depentent on the shape of the lookup where otherwise we'd compute the
same VN.

I'm quite sure we can't simply trust TYPE_DOMAIN of TREE_TYPE of
TREE_OPERAND (array-ref, 0) when constraining operand 1.

Reply via email to