[PATCH] Fix InstCombine vector bitcasts for big-endian

Eli Friedman eli.friedman at gmail.com
Fri Aug 9 21:04:40 PDT 2013


On Thu, Aug 8, 2013 at 2:04 AM, Richard Sandiford
<rsandifo at linux.vnet.ibm.com> wrote:
> MultiSource/Benchmarks/mediabench/gsm/toast started failing on z after
> SLP was enabled by default.  I think this was just tripping over a latent
> endianness bug in the way that integer-to-vector bitcasts are handled by
> InstCombine.  All the current logic assumes that the lsb of an integer
> corresponds to vector element 0, whereas for big-endian it's the other way
> around: the msb is in the first element and the lsb is in the last element.
>
> One fix would be to handle the endianness difference every time we
> calculate an index, but that looked horrible.  Another would have been
> to assume little-endian ordering until a paricular point, and then
> switch to big-endian (e.g. when assigning to Elements[]), but that
> seemed error-prone.  So in the end I thought it'd be better to pass
> around a shift amount instead of a vector index, since shift amounts
> don't depend on endianness.
>
> For tests I copied the remaining @test* functions from bitcast.ll to
> bitcast-bigendian.ll and adjusted the expected output accordingly.
>
> OK to commit?

LGTM.

-Eli



More information about the llvm-commits mailing list