[llvm] [SLP] Delete vectorized users when tree contains an invalid cost (PR #86344)

Patrick O'Neill via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 22 14:36:30 PDT 2024


patrick-rivos wrote:

ICE Backtrace (added debug trace to show all the offending ops):
```
ReductionOps Deleting   %zext.1 = zext to i32 with users:  %or.4 = or i32 %or.3, %zext.1.
ReductionOps Deleting   %zext.2 = zext to i32 with users:  %or.5 = or i32 %or.4, %zext.2.
ReductionOps Deleting   %zext.3 = zext to i32 with users:  %or.6 = or i32 %or.5, %zext.3.
ReductionOps Deleting   %zext.0 = zext to i32 with users:  %or.3 = or i32 %or.2, %zext.0.
opt: /scratch/tc-testing/tc-mar-5-llvm-slp-ice-2/llvm/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:3788: llvm::slpvectorizer::BoUpSLP::~BoUpSLP(): Assertion `I->use_empty() && "trying to erase instruction with users."' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
```

Explanation:
```
(Store.this)
     |
   (or.3-6)
   ////   \
zext[1]  (or.0-2)
         |||\
        trunc i96 [2]
           // \\
	 lshr  add [3]
```

[1] This operation gets vectorized. or.3-6 still exist and are not cleaned up.

Begin evaluating tree of depth 2 ([2] and [3]):
[2] The truncations are considered and return an invalid cost. This is due to
    risc-v not having a vector op with SEW > 64.
[3] Also considered and rejected (because they are i96 ops).

! At this point we return a null ptr _without_ running the [cleanup code](https://github.com/llvm/llvm-project/blob/718fbbef5f18a2b7e7fc4f842b1452ae9bee581a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp#L16064-L16200).

All other vectorization attempts either bail or are unprofitable which causes
the cleanup code to never run for `or.3-6`

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


More information about the llvm-commits mailing list