[PATCH] D79452: [VectorCombine] scalarize binop of inserted elements into vector constants

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 7 10:14:24 PDT 2020


spatel marked an inline comment as done.
spatel added inline comments.


================
Comment at: llvm/test/Transforms/VectorCombine/X86/insert-binop.ll:102
   %i0 = insertelement <2 x i64> <i64 42, i64 -42>, i64 %x, i64 1
   %i1 = insertelement <2 x i64> <i64 -7, i64 128>, i64 %y, i32 1
   %r = sdiv <2 x i64> %i0, %i1
----------------
RKSimon wrote:
> Can we ever have a base vector with undef elements here? sdiv/udiv won't like that but I'm not sure if we can ever get in that state.
> ```
>   %i0 = insertelement <2 x i64> <i64 42, i64 undef>, i64 %x, i64 1
>   %i1 = insertelement <2 x i64> <i64 -7, i64 undef>, i64 %y, i32 1
> ```
Yes, it's ok to have undefs in the lane that we're inserting into, and ConstantFolding will deal with that. Demanded elements will eventually replace the unused constants that we see in this test with undefs.

We can't, however, have undefs in lanes we are not inserting into with div/rem - that would be immediate UB, so we would have simplified that before we reach here. But I can add tests with non-canonical IR to make sure there's nothing crazy happening here.


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

https://reviews.llvm.org/D79452





More information about the llvm-commits mailing list