[llvm] [SLP]Analyze widened reduction leaves in the narrow type (PR #216062)

Alexey Bataev via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 22 17:50:20 PDT 2026


alexey-bataev wrote:

> This change causes failed asserts for me:
> 
> ```c++
> typedef long long a;
> enum { b, d, e = 32, f };
> struct n {
>   a h;
>   n(a q) : h(q) {}
>   static n j(short q, short z, short aa) { return q | z << d | a(aa) << f; }
>   static n l(unsigned char q, unsigned char z, unsigned aa) {
>     n m = j(q, z, aa);
>     return m;
>   }
> };
> struct ab {
>   enum o { p };
> };
> struct af;
> typedef const unsigned *(*r)(unsigned *, const unsigned *, int, const af *,
>                              const unsigned *);
> typedef const n *(*s)(n *, const unsigned *, int, const af *, const unsigned *);
> enum t {};
> struct af {
>   char u;
>   char v;
>   char w;
>   char x;
>   char y;
>   char c;
>   char b;
>   char d;
>   bool e;
>   t ac;
>   r ad;
>   r ae;
>   r f;
>   s ag;
> };
> template <ab::o> t ah();
> template <ab::o>
> const unsigned *ai(unsigned *, const unsigned *, int, const af *,
>                    const unsigned *);
> template <int>
> const n *aj(n *q, const unsigned *z, int, const af *, const unsigned *) {
>   int a, b, c = b = 6;
>   char d = 8 - b;
>   for (int i;; ++i) {
>     a = 1;
>     int k(z[i] >> a);
>     int e(z[i] >> 5);
>     int f = z[i] & c;
>     e = e << d | e >> 2;
>     f = f << 5 | f >> 2;
>     q[i] = n::l(k, e, f);
>   }
> }
> template <ab::o>
> const unsigned *ak(unsigned *, const unsigned *, int, const af *,
>                    const unsigned *);
> template <ab::o>
> const unsigned *al(unsigned *, const unsigned *, int, const af *,
>                    const unsigned *);
> template <ab::o o> af am() {
>   return {char(), char(), char(),  char(), char(), char(), 0,
>           0,      false,  ah<o>(), ai<o>,  ak<o>,  al<o>,  aj<o>};
> }
> af g{am<ab::p>()};
> ```
> 
> ```
> $ clang -target aarch64-linux-gnu -c -O2 repro.cpp
> clang: ../lib/Transforms/Vectorize/SLPVectorizer.cpp:2511: void llvm::slpvectorizer::BoUpSLP::removeInstructionsAndOperands(llvm::ArrayRef<BlockT*>, llvm::ArrayRef<std::tuple<llvm::WeakTrackingVH, unsigned int, bool, bool> >) [with T = llvm::Instruction]: Assertion `(I->use_empty() || all_of(I->uses(), [&](Use &U) { return isDeleted( cast<Instruction>(U.getUser())); })) && "trying to erase instruction with users."' failed.
> ```

Must be fixed in a0dba475907bc6b344eca022541eb67018915612

https://github.com/llvm/llvm-project/pull/216062


More information about the llvm-commits mailing list