PR #10474: memcmp is not valid for comparing 4 bit types
PR #10474: memcmp is not valid for comparing 4 bit types

Imported from GitHub PR https://github.com/openxla/xla/pull/10474

To compare the subshape of a literal that is a 4 bit type it is not valid to compare the memory with memcmp as the upper nibble of each byte may not be initialised and result in a false failure of the comparison. Instead detect this situation and compare each nibble that will hold the 4 bit type.
Copybara import of the project:

--
760978ed02c6f28cb13cc7775b85f9f28b48d977 by Andrew Goodbody <andrew.goodbody@linaro.org>:

memcmp is not valid for comparing 4 bit types

To compare the subshape of a literal that is a 4 bit type
it is not valid to compare the memory with memcmp as the
upper nibble of each byte may not be initialised and result
in a false failure of the comparison. Instead detect this
situation and compare each nibble that will hold the 4 bit
type.

Merging this change closes #10474

FUTURE_COPYBARA_INTEGRATE_REVIEW=https://github.com/openxla/xla/pull/10474 from elfringham:fix_literal 760978ed02c6f28cb13cc7775b85f9f28b48d977
