[PATCH] D31509: [InstCombine] Combine vector shuffles if the same operand can be reused

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 4 14:29:22 PDT 2017


efriedma added a comment.

Try the following on x86 (with SSE2 only):

  #include <xmmintrin.h>
  __m128i f(__m128i z) {
    return _mm_unpacklo_epi8(_mm_unpacklo_epi8(z, z), _mm_unpackhi_epi8(z, z));
  }

Granted, the x86 backend currently manages to screw this up even without help from instcombine, but the point is that shuffle lowering is extremely fragile if we don't have perfect shuffle tables or a general shuffle instruction.

I'm not exactly enthusiastic about a TTI hook here; I mean, it solves the problem in some sense, but I don't want to create a situation where our optimization pipeline becomes overly dependent on the presence of a general shuffle instruction.


https://reviews.llvm.org/D31509





More information about the llvm-commits mailing list