[llvm] [VectorCombine] foldShuffleOfCastops - handle unary shuffles (PR #160009)

Chaitanya Koparkar via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 23 06:13:45 PDT 2025


================
@@ -922,10 +922,9 @@ define <4 x i8> @singleop(<4 x i8> %a, <4 x i8> %b) {
 
 define <4 x i64> @cast_mismatched_types(<4 x i32> %x) {
 ; CHECK-LABEL: @cast_mismatched_types(
-; CHECK-NEXT:    [[SHUF:%.*]] = shufflevector <4 x i32> [[X:%.*]], <4 x i32> poison, <2 x i32> <i32 0, i32 2>
-; CHECK-NEXT:    [[ZEXT:%.*]] = zext <2 x i32> [[SHUF]] to <2 x i64>
-; CHECK-NEXT:    [[EXTSHUF:%.*]] = shufflevector <2 x i64> [[ZEXT]], <2 x i64> poison, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
-; CHECK-NEXT:    ret <4 x i64> [[EXTSHUF]]
+; CHECK-SAME: <4 x i32> [[X:%.*]]) {
+; CHECK-NEXT:    [[ZEXT:%.*]] = zext <4 x i32> [[X]] to <4 x i64>
+; CHECK-NEXT:    ret <4 x i64> [[ZEXT]]
----------------
ckoparkar wrote:

Is this correct, is ` <20, poison, 30, poison>` equivalent to ` <20, 10, 30, 40>`?

```
; cast_mismatched_types(<20, 10, 30, 40>)
; shuf = shufflevector %x, poison, <0, 2>             : 2 x i32
;      = <20, 30>                                     : 2 x i32
;
; zext = <20, 30>                                     : 2 x i64
;
; extshuf = shufflevector %zext, poison, <0, 2, 1, 3> : 4 x i64
;         = <20, poison, 30, poison>                  : 4 x i64
```

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


More information about the llvm-commits mailing list