[llvm] [LoongArch] Remove wrong vector shuffle lowering for lasx. (PR #140688)

via llvm-commits llvm-commits at lists.llvm.org
Tue May 20 08:37:28 PDT 2025


================
@@ -40,24 +40,4 @@ define <8 x float> @shufflevector_xvshuf4i_v8f32(<8 x float> %a, <8 x float> %b)
 ; CHECK-NEXT:    ret
     %c = shufflevector <8 x float> %a, <8 x float> %b, <8 x i32> <i32 3, i32 2, i32 1, i32 0, i32 7, i32 6, i32 5, i32 4>
     ret <8 x float> %c
-}
-
-;; xvshuf4i.d
-define <4 x i64> @shufflevector_xvshuf4i_v4d64(<4 x i64> %a, <4 x i64> %b) {
-; CHECK-LABEL: shufflevector_xvshuf4i_v4d64:
-; CHECK:       # %bb.0:
-; CHECK-NEXT:    xvshuf4i.d $xr0, $xr1, 9
-; CHECK-NEXT:    ret
-    %c = shufflevector <4 x i64> %a, <4 x i64> %b, <4 x i32> <i32 1, i32 2, i32 5, i32 6>
-    ret <4 x i64> %c
-}
----------------
heiher wrote:

Ah, I see, that was definitely incorrect.

The element ordering in `XVSHUF4I.D` doesn't actually align with `shufflevector` semantics. The correct mapping after transformation is:

```
vec : {vj[3], vj[2], vd[3], vd[2], vj[1], vj[0], vd[1], vd[0]}
mask:     7      6      3      2      5      4      1      0
```

It seems possible to lower the following case using `XVSHUF4I.D`:

```ll
define <4 x i64> @shufflevector_xvshuf4i_v4d64(<4 x i64> %a, <4 x i64> %b) {		
; CHECK-LABEL: shufflevector_xvshuf4i_v4d64:
; CHECK:       # %bb.0:		
; CHECK-NEXT:    xvshuf4i.d $xr0, $xr1, 9		
; CHECK-NEXT:    ret		
    %c = shufflevector <4 x i64> %a, <4 x i64> %b, <4 x i32> <i32 1, i32 4, i32 3, i32 6>		
    ret <4 x i64> %c		
}
```

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


More information about the llvm-commits mailing list