Skip to content
  • Chandler Carruth's avatar
    [x86] Largely complete the use of PSHUFB in the new vector shuffle · 4c57955f
    Chandler Carruth authored
    lowering with a small addition to it and adding PSHUFB combining.
    
    There is one obvious place in the new vector shuffle lowering where we
    should form PSHUFBs directly: when without them we will unpack a vector
    of i8s across two different registers and do a potentially 4-way blend
    as i16s only to re-pack them into i8s afterward. This is the crazy
    expensive fallback path for i8 shuffles and we can just directly use
    pshufb here as it will always be cheaper (the unpack and pack are
    two instructions so even a single shuffle between them hits our
    three instruction limit for forming PSHUFB).
    
    However, this doesn't generate very good code in many cases, and it
    leaves a bunch of common patterns not using PSHUFB. So this patch also
    adds support for extracting a shuffle mask from PSHUFB in the X86
    lowering code, and uses it to handle PSHUFBs in the recursive shuffle
    combining. This allows us to combine through them, combine multiple ones
    together, and generally produce sufficiently high quality code.
    
    Extracting the PSHUFB mask is annoyingly complex because it could be
    either pre-legalization or post-legalization. At least this doesn't have
    to deal with re-materialized constants. =] I've added decode routines to
    handle the different patterns that show up at this level and we dispatch
    through them as appropriate.
    
    The two primary test cases are updated. For the v16 test case there is
    still a lot of room for improvement. Since I was going through it
    systematically I left behind a bunch of FIXME lines that I'm hoping to
    turn into ALL lines by the end of this.
    
    llvm-svn: 214628
    4c57955f
Loading