[PATCH] D135876: [VectorCombine] Scalarize binops with insertelt nested inside splats

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 17 11:04:04 PDT 2022


spatel requested changes to this revision.
spatel added a comment.
This revision now requires changes to proceed.

If the motivating case always ends in a splat, could we do this in instcombine instead?

This is an improvement for the specific patterns where it is allowed, but it needs to account for possibly several other patterns where it is changing code in ways that the original transform did not anticipate. For example, this can currently miscompile (tested with aarch64 and x86 targets):

  define <4 x i32> @insert_splat_sub(i32 %x, i32 %y) {
    %x111 = insertelement <4 x i32> <i32 1, i32 1, i32 1, i32 1>, i32 %x, i64 0
    %y567 = insertelement <4 x i32> <i32 4, i32 5, i32 6, i32 7>, i32 %y, i64 0
    %yyyy = shufflevector <4 x i32> %y567, <4 x i32> poison, <4 x i32> zeroinitializer
    %r = sub <4 x i32> %x111, %yyyy
    ret <4 x i32> %r
  }


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135876/new/

https://reviews.llvm.org/D135876



More information about the llvm-commits mailing list