[llvm] [SLP] Pessimistically handle unknown vector entries in SLP vectorizer (PR #75438)

Alexey Bataev via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 14 04:39:48 PST 2023


alexey-bataev wrote:

> > Ok, let's fix it this way for now, later need to teach getInsertIndex to separate representation for undef/runtime indices
> 
> Alright. Thank you for your review.
> 
> Also, while analyzing the issue. I figured there were cases where SLP inserts seemingly redundant shuffles. For example here:
> 
> ![image](https://private-user-images.githubusercontent.com/4027748/290513605-f55893a8-a125-463e-9355-57ed33155600.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTEiLCJleHAiOjE3MDI1NTc0NjUsIm5iZiI6MTcwMjU1NzE2NSwicGF0aCI6Ii80MDI3NzQ4LzI5MDUxMzYwNS1mNTU4OTNhOC1hMTI1LTQ2M2UtOTM1NS01N2VkMzMxNTU2MDAucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQUlXTkpZQVg0Q1NWRUg1M0ElMkYyMDIzMTIxNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyMzEyMTRUMTIzMjQ1WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MTIxMGI5Y2MwNGJkMmM2MzBmYTMyNWZjMzU1MWRhNmZhNDY4YjAwZGZkNWJjOTY1MWU0OWI2OTQ1NzJjNDhjZiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.BlRWnMqbkA3q7flVt_Jo6QBx5Rl5Et5ReRA_Ao53JgI)
> 
> `%122` on the left is replaced by 3 shuffles. The last two shuffles expand (`%128`) and merge (`%129`) the vector, however the first shuffle (`%127`) is not being referenced anywhere else in the remaining code (that I can unfortunately not screenshot).
> 
> While the redundant shuffle will eventually be removed later by DCE, I am still curious, is there a known reason this happens?

2 of these shuffles are free,they are just identity resizing shuffles, so it is not a big issue + they will optimized later. Yes, this can be improved, working on this. It may help if you can provide the reproducer

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


More information about the llvm-commits mailing list