[all-commits] [llvm/llvm-project] a4c466: [InstCombine] canonicalize trunc + insert as bitca...

Sanjay Patel via All-commits all-commits at lists.llvm.org
Wed Nov 30 10:23:36 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a4c466766db77cd1fb42d7f98f32bb87a3d38829
      https://github.com/llvm/llvm-project/commit/a4c466766db77cd1fb42d7f98f32bb87a3d38829
  Author: Sanjay Patel <spatel at rotateright.com>
  Date:   2022-11-30 (Wed, 30 Nov 2022)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
    M llvm/test/Transforms/InstCombine/insert-trunc.ll
    M llvm/test/Transforms/InstCombine/vec_phi_extract-inseltpoison.ll
    M llvm/test/Transforms/InstCombine/vec_phi_extract.ll
    M llvm/test/Transforms/LoopVectorize/ARM/pointer_iv.ll
    M llvm/test/Transforms/PhaseOrdering/X86/vec-load-combine.ll

  Log Message:
  -----------
  [InstCombine] canonicalize trunc + insert as bitcast + shuffle, part 1

This is the main patch for converting a truncated scalar that is
inserted into a vector to bitcast+shuffle. We could go either way
on patterns like this, but this direction will allow collapsing a
pair of these sequences on the motivating example from issue

The patch is split into 3 parts to make it easier to see the
progression of tests diffs. We allow inserting/shuffling into a
different size vector for flexibility, so there are several test
variations. The length-changing is handled by shortening/padding
the shuffle mask with undef elements.

In part 1, handle the basic pattern:
inselt undef, (trunc T), IndexC --> shuffle (bitcast T), IdentityMask

Proof for the endian-dependency behaving as expected:
https://alive2.llvm.org/ce/z/BsA7yC

The TODO items for handling shifts and insert into an arbitrary base
vector value are implemented as follow-ups.

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




More information about the All-commits mailing list