[llvm] [SLP][NFC]Add an extra test with the reodering of the aggregate bitpacks, NFC (PR #229380)

Alexey Bataev via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 6 04:02:54 PDT 2026


https://github.com/alexey-bataev created https://github.com/llvm/llvm-project/pull/229380

None

>From 22ddf4a57876fbc46dfaf7168f5707d6ca85a1f8 Mon Sep 17 00:00:00 2001
From: Alexey Bataev <a.bataev at outlook.com>
Date: Tue, 6 Oct 2026 04:02:38 -0700
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.7
---
 .../SLPVectorizer/X86/bitpacked-aggregate.ll  | 54 +++++++++++++++++++
 1 file changed, 54 insertions(+)

diff --git a/llvm/test/Transforms/SLPVectorizer/X86/bitpacked-aggregate.ll b/llvm/test/Transforms/SLPVectorizer/X86/bitpacked-aggregate.ll
index 9eb2b060e3781df..67a77726a9e9546 100644
--- a/llvm/test/Transforms/SLPVectorizer/X86/bitpacked-aggregate.ll
+++ b/llvm/test/Transforms/SLPVectorizer/X86/bitpacked-aggregate.ll
@@ -577,6 +577,60 @@ entry:
   ret { i64, i64 } %a1
 }
 
+; The order of the fields is reversed to the memory order.
+
+define { i64, i64 } @pack_reversed(ptr %x, ptr %y) {
+; CHECK-LABEL: @pack_reversed(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[VEC2STRUCT_SLOT:%.*]] = alloca { i64, i64 }, align 16
+; CHECK-NEXT:    [[TMP0:%.*]] = load <4 x i32>, ptr [[X:%.*]], align 4
+; CHECK-NEXT:    [[TMP1:%.*]] = load <4 x i32>, ptr [[Y:%.*]], align 4
+; CHECK-NEXT:    [[TMP2:%.*]] = shufflevector <4 x i32> [[TMP0]], <4 x i32> poison, <2 x i32> <i32 2, i32 0>
+; CHECK-NEXT:    [[TMP3:%.*]] = shufflevector <4 x i32> [[TMP1]], <4 x i32> poison, <2 x i32> <i32 2, i32 0>
+; CHECK-NEXT:    [[TMP4:%.*]] = call <2 x i32> @llvm.smin.v2i32(<2 x i32> [[TMP2]], <2 x i32> [[TMP3]])
+; CHECK-NEXT:    [[TMP5:%.*]] = shufflevector <4 x i32> [[TMP0]], <4 x i32> poison, <2 x i32> <i32 3, i32 1>
+; CHECK-NEXT:    [[TMP6:%.*]] = shufflevector <4 x i32> [[TMP1]], <4 x i32> poison, <2 x i32> <i32 3, i32 1>
+; CHECK-NEXT:    [[TMP7:%.*]] = call <2 x i32> @llvm.smin.v2i32(<2 x i32> [[TMP5]], <2 x i32> [[TMP6]])
+; CHECK-NEXT:    [[TMP8:%.*]] = zext <2 x i32> [[TMP7]] to <2 x i64>
+; CHECK-NEXT:    [[TMP9:%.*]] = zext <2 x i32> [[TMP4]] to <2 x i64>
+; CHECK-NEXT:    [[TMP10:%.*]] = shl nuw <2 x i64> [[TMP9]], splat (i64 32)
+; CHECK-NEXT:    [[TMP11:%.*]] = or disjoint <2 x i64> [[TMP10]], [[TMP8]]
+; CHECK-NEXT:    store <2 x i64> [[TMP11]], ptr [[VEC2STRUCT_SLOT]], align 16
+; CHECK-NEXT:    [[AGG_1:%.*]] = load { i64, i64 }, ptr [[VEC2STRUCT_SLOT]], align 16
+; CHECK-NEXT:    ret { i64, i64 } [[AGG_1]]
+;
+entry:
+  %x.1.p = getelementptr inbounds i32, ptr %x, i64 1
+  %y.1.p = getelementptr inbounds i32, ptr %y, i64 1
+  %x.2.p = getelementptr inbounds i32, ptr %x, i64 2
+  %y.2.p = getelementptr inbounds i32, ptr %y, i64 2
+  %x.3.p = getelementptr inbounds i32, ptr %x, i64 3
+  %y.3.p = getelementptr inbounds i32, ptr %y, i64 3
+  %x.0 = load i32, ptr %x, align 4
+  %y.0 = load i32, ptr %y, align 4
+  %m.3 = call i32 @llvm.smin.i32(i32 %x.0, i32 %y.0)
+  %x.1 = load i32, ptr %x.1.p, align 4
+  %y.1 = load i32, ptr %y.1.p, align 4
+  %m.2 = call i32 @llvm.smin.i32(i32 %x.1, i32 %y.1)
+  %x.2 = load i32, ptr %x.2.p, align 4
+  %y.2 = load i32, ptr %y.2.p, align 4
+  %m.1 = call i32 @llvm.smin.i32(i32 %x.2, i32 %y.2)
+  %x.3 = load i32, ptr %x.3.p, align 4
+  %y.3 = load i32, ptr %y.3.p, align 4
+  %m.0 = call i32 @llvm.smin.i32(i32 %x.3, i32 %y.3)
+  %z.0 = zext i32 %m.0 to i64
+  %z.1 = zext i32 %m.1 to i64
+  %s.1 = shl nuw i64 %z.1, 32
+  %w.0 = or disjoint i64 %s.1, %z.0
+  %agg.0 = insertvalue { i64, i64 } poison, i64 %w.0, 0
+  %z.2 = zext i32 %m.2 to i64
+  %z.3 = zext i32 %m.3 to i64
+  %s.3 = shl nuw i64 %z.3, 32
+  %w.1 = or disjoint i64 %s.3, %z.2
+  %agg.1 = insertvalue { i64, i64 } %agg.0, i64 %w.1, 1
+  ret { i64, i64 } %agg.1
+}
+
 ; The packs below are not vectorized together.
 
 ; Extra use of a pack instruction.



More information about the llvm-commits mailing list