[all-commits] [llvm/llvm-project] f13305: [VectorCombine] Fold deinterleave2 with smaller ef...

Min-Yih Hsu via All-commits all-commits at lists.llvm.org
Wed May 27 14:56:41 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f13305bac8ea2237e6fbab29f172e6a5a5058a1c
      https://github.com/llvm/llvm-project/commit/f13305bac8ea2237e6fbab29f172e6a5a5058a1c
  Author: Min-Yih Hsu <min.hsu at sifive.com>
  Date:   2026-05-27 (Wed, 27 May 2026)

  Changed paths:
    M llvm/lib/Transforms/Vectorize/VectorCombine.cpp
    A llvm/test/Transforms/VectorCombine/RISCV/vector-deinterleave2.ll

  Log Message:
  -----------
  [VectorCombine] Fold deinterleave2 with smaller effective element size (#192121)

Found in real-world code where this sequence:
```
%d = llvm.vector.deinterleave2 <vscale x 16 x i32> %v
%f0 = extractvalue { <vscale x 8 x i32>, <vscale x 8 x i32> } %d, 0
%f1 = extractvalue { <vscale x 8 x i32>, <vscale x 8 x i32> } %d, 1

%low0 = and <vscale x 8 x i32> %f0, splat (i32 65535)
%low1 = shl <vscale x 8 x i32> %f1, splat (i32 16)
%merge0 = or disjoint <vscale x 8 x i32> %low0, %low1

%high0 = and <vscale x 8 x i32> %f1, splat (i32 -65536)
%high1 = lshr <vscale x 8 x i32> %f0, splat (i32 16)
%merge1 = or disjoint <vscale x 8 x i32> %high0, %high1
```
is really just doing `deinterleave2` but on `<vscale x 32 x i16>`. That
is, the same total vector size but with half the element width. So we
can turn it into:
```
%narrow.v = bitcast <vscale x 16 x i32> %v to <vscale x 32 x i16>
%d = llvm.vector.deinterleave2 <vscale x 32 x i16> %narrow.v
%f0 = extractvalue { <vscale x 16 x i16>, <vscale x 16 x i16> } %d, 0
%f1 = extractvalue { <vscale x 16 x i16>, <vscale x 16 x i16> } %d, 1

%merge0 = bitcast <vscale x 16 x i16> %f0 to <vscale x 8 x i32>
%merge1 = bitcast <vscale x 16 x i16> %f1 to <vscale x 8 x i32>
```
I put this in VectorCombine because I'm worried that the newly created
bitcast might be expensive for some targets, hence a profitability check
before committing the transformation.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list