[llvm] [AArch64] - Improve costing for Identity shuffles for SVE targets. (PR #165375)

Pawan Nirpal via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 3 05:25:19 PST 2025


pawan-nirpal-031 wrote:

> > it causes some other shuffle pattern costs to change
> 
> Do you have an example of where it changed the cost negatively? (I can imagine it could, but it would be interesting which cases are causing problems and if we could add testing for them).

Following are the cases, where cost goes up unmitigated

Failed Tests (3):
  LLVM :: Analysis/CostModel/AArch64/shuffle-broadcast.ll For this test, the failing case is 
  ```
; CHECK-NEXT: Cost Model: Found costs of 0 for: %v2i8 = shufflevector <2 x i8> undef, <2 x i8> undef, <1 x i32> zeroinitializer
              ^
<stdin>:40:70: note: scanning from here
Printing analysis 'Cost Model Analysis' for function 'broadcast_half':
                                                                     ^
<stdin>:41:1: note: possible intended match here
Cost Model: Found costs of 1 for: %v2i8 = shufflevector <2 x i8> undef, <2 x i8> undef, <1 x i32> zeroinitializer
  ```
  
  LLVM :: Analysis/CostModel/AArch64/shuffle-extract.ll for this test the case is
```
; CHECK-NEXT: Cost Model: Found costs of 0 for: %v2i8_lo = shufflevector <2 x i8> poison, <2 x i8> poison, <1 x i32> zeroinitializer
              ^
<stdin>:1:68: note: scanning from here
Printing analysis 'Cost Model Analysis' for function 'extract_half':
                                                                   ^
<stdin>:2:1: note: possible intended match here
Cost Model: Found costs of 1 for: %v2i8_lo = shufflevector <2 x i8> poison, <2 x i8> poison, <1 x i32> zeroinitializer
```
  LLVM :: Analysis/CostModel/AArch64/shuffle-load.ll
  
  ```
; CHECK-NEXT: Cost Model: Found costs of 1 for: %v4i8_0 = shufflevector <4 x i8> %v4i8, <4 x i8> undef, <2 x i32> <i32 0, i32 2>
              ^
<stdin>:108:106: note: scanning from here
Cost Model: Found costs of RThru:2 CodeSize:1 Lat:4 SizeLat:1 for: %v4i8 = load <4 x i8>, ptr %p, align 4
                                                                                                         ^
<stdin>:109:1: note: possible intended match here
Cost Model: Found costs of 4 for: %v4i8_0 = shufflevector <4 x i8> %v4i8, <4 x i8> undef, <2 x i32> <i32 0, i32 2>
^
  ```

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


More information about the llvm-commits mailing list