[PATCH] [InstCombine] Fix big-endian miscompile of (bitcast (zext/trunc (bitcast)))
authorBjorn Pettersson <bjorn.a.pettersson@ericsson.com>
Thu, 28 Nov 2019 22:18:28 +0000 (23:18 +0100)
committerGianfranco Costamagna <locutusofborg@debian.org>
Sat, 15 Aug 2020 19:53:41 +0000 (20:53 +0100)
commitb30ae6aa06f74335ca2136acc1da0f02611d4b29
tree55f69f1e9146aeaff7bef53c0f4a3d1823b46304
parent700a4a182670272443cbcb6db0766cb4633af061
[PATCH] [InstCombine] Fix big-endian miscompile of (bitcast (zext/trunc (bitcast)))

Summary:
optimizeVectorResize is rewriting patterns like:
  %1 = bitcast vector %src to integer
  %2 = trunc/zext %1
  %dst = bitcast %2 to vector

Since bitcasting between integer an vector types gives
different integer values depending on endianness, we need
to take endianness into account. As it happens the old
implementation only produced the correct result for little
endian targets.

Fixes: https://bugs.llvm.org/show_bug.cgi?id=44178
Reviewers: spatel, lattner, lebedev.ri

Reviewed By: spatel, lebedev.ri

Subscribers: lebedev.ri, hiraditya, uabelho, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D70844

(cherry picked from commit a9d6b0e5444741d08ff1df7cf71d1559e7fefc1f)

Gbp-Pq: Name f8e146f3430de3a6cd904f3f3f7aa1bfaefee14c.patch
llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
llvm/test/Transforms/InstCombine/cast.ll