From 2292d53b7b5dc3989167e753d3ac4422b321b426 Mon Sep 17 00:00:00 2001 From: ritik chahar Date: Sun, 1 Feb 2026 21:41:43 +0530 Subject: [PATCH 1/8] Add codegen test for SLP vectorization --- tests/codegen-llvm/slp-vectorization-mul3.rs | 23 ++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/codegen-llvm/slp-vectorization-mul3.rs diff --git a/tests/codegen-llvm/slp-vectorization-mul3.rs b/tests/codegen-llvm/slp-vectorization-mul3.rs new file mode 100644 index 0000000000000..a414192e6a1a4 --- /dev/null +++ b/tests/codegen-llvm/slp-vectorization-mul3.rs @@ -0,0 +1,23 @@ +// compile-flags: -O +#![crate_type = "lib"] + +// CHECK-LABEL: mul3 +// CHECK: %[[C_BPP:.*]] = phi <4 x i8> +// CHECK: %[[V:.*]] = load <4 x i8>, ptr +// CHECK: %[[ADD:.*]] = add <4 x i8> %[[V]], %[[C_BPP]] +// CHECK: store {{<4 x i8>|i32}} {{.*}}, ptr + +pub fn mul3(previous: &[u8], current: &mut [u8]) { + let mut c_bpp = [0u8; 4]; + + for (chunk, b_bpp) in current.chunks_exact_mut(4).zip(previous.chunks_exact(4)) { + let new_chunk = [ + chunk[0].wrapping_add(c_bpp[0]), + chunk[1].wrapping_add(c_bpp[1]), + chunk[2].wrapping_add(c_bpp[2]), + chunk[3].wrapping_add(c_bpp[3]), + ]; + chunk.copy_from_slice(&new_chunk); + c_bpp.copy_from_slice(b_bpp); + } +} \ No newline at end of file From 0a60bd653d3bd42752e4e454567ae5fcb96a2b49 Mon Sep 17 00:00:00 2001 From: ritik chahar Date: Sun, 1 Feb 2026 22:09:05 +0530 Subject: [PATCH 2/8] fix: remove trailing newline for tidy --- tests/codegen-llvm/slp-vectorization-mul3.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/codegen-llvm/slp-vectorization-mul3.rs b/tests/codegen-llvm/slp-vectorization-mul3.rs index a414192e6a1a4..7a69be5cafb75 100644 --- a/tests/codegen-llvm/slp-vectorization-mul3.rs +++ b/tests/codegen-llvm/slp-vectorization-mul3.rs @@ -20,4 +20,4 @@ pub fn mul3(previous: &[u8], current: &mut [u8]) { chunk.copy_from_slice(&new_chunk); c_bpp.copy_from_slice(b_bpp); } -} \ No newline at end of file +} From 1c396d24ddf97d556d41487234f6216b67461b7c Mon Sep 17 00:00:00 2001 From: ritik chahar Date: Sun, 1 Feb 2026 22:14:13 +0530 Subject: [PATCH 3/8] Restrict test to x86_64 per reviewer feedback --- tests/codegen-llvm/slp-vectorization-mul3.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/codegen-llvm/slp-vectorization-mul3.rs b/tests/codegen-llvm/slp-vectorization-mul3.rs index 7a69be5cafb75..bb4965c46bc0e 100644 --- a/tests/codegen-llvm/slp-vectorization-mul3.rs +++ b/tests/codegen-llvm/slp-vectorization-mul3.rs @@ -1,4 +1,6 @@ -// compile-flags: -O +//@ only-x86_64 +//@ compile-flags: -O + #![crate_type = "lib"] // CHECK-LABEL: mul3 From c64f9a0fc46fecb8ccb15d1ab1fcfd83ce94b5e5 Mon Sep 17 00:00:00 2001 From: ritik chahar Date: Mon, 2 Feb 2026 07:38:14 +0530 Subject: [PATCH 4/8] Add backlink to issue --- tests/codegen-llvm/slp-vectorization-mul3.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/codegen-llvm/slp-vectorization-mul3.rs b/tests/codegen-llvm/slp-vectorization-mul3.rs index bb4965c46bc0e..b6edc212c82d9 100644 --- a/tests/codegen-llvm/slp-vectorization-mul3.rs +++ b/tests/codegen-llvm/slp-vectorization-mul3.rs @@ -1,3 +1,4 @@ +//! Regression test for #142519 //@ only-x86_64 //@ compile-flags: -O From 95ac5673cedf8b0ba543aac2ccb67b47f60662e1 Mon Sep 17 00:00:00 2001 From: ritik chahar Date: Mon, 2 Feb 2026 15:38:26 +0530 Subject: [PATCH 5/8] Fix SLP vectorization test CHECK patterns --- tests/codegen-llvm/slp-vectorization-mul3.rs | 29 ++++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/tests/codegen-llvm/slp-vectorization-mul3.rs b/tests/codegen-llvm/slp-vectorization-mul3.rs index b6edc212c82d9..1c40c6b28f3ff 100644 --- a/tests/codegen-llvm/slp-vectorization-mul3.rs +++ b/tests/codegen-llvm/slp-vectorization-mul3.rs @@ -4,23 +4,22 @@ #![crate_type = "lib"] -// CHECK-LABEL: mul3 -// CHECK: %[[C_BPP:.*]] = phi <4 x i8> -// CHECK: %[[V:.*]] = load <4 x i8>, ptr -// CHECK: %[[ADD:.*]] = add <4 x i8> %[[V]], %[[C_BPP]] -// CHECK: store {{<4 x i8>|i32}} {{.*}}, ptr +// CHECK-LABEL: @mul3 +// CHECK: phi <4 x i8> +// CHECK: load <4 x i8> +// CHECK: add <4 x i8> +// CHECK: store <4 x i8> -pub fn mul3(previous: &[u8], current: &mut [u8]) { +#[no_mangle] +pub fn mul3(previous: &[[u8; 4]], current: &mut [[u8; 4]]) { let mut c_bpp = [0u8; 4]; - for (chunk, b_bpp) in current.chunks_exact_mut(4).zip(previous.chunks_exact(4)) { - let new_chunk = [ - chunk[0].wrapping_add(c_bpp[0]), - chunk[1].wrapping_add(c_bpp[1]), - chunk[2].wrapping_add(c_bpp[2]), - chunk[3].wrapping_add(c_bpp[3]), - ]; - chunk.copy_from_slice(&new_chunk); - c_bpp.copy_from_slice(b_bpp); + for i in 0..previous.len() { + current[i][0] = current[i][0].wrapping_add(c_bpp[0]); + current[i][1] = current[i][1].wrapping_add(c_bpp[1]); + current[i][2] = current[i][2].wrapping_add(c_bpp[2]); + current[i][3] = current[i][3].wrapping_add(c_bpp[3]); + + c_bpp = previous[i]; } } From 0830a5a9286e351a009e8eaa1fa86691e3a3b62e Mon Sep 17 00:00:00 2001 From: ritik chahar Date: Mon, 2 Feb 2026 15:44:50 +0530 Subject: [PATCH 6/8] fix: add min-llvm-version --- tests/codegen-llvm/slp-vectorization-mul3.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/codegen-llvm/slp-vectorization-mul3.rs b/tests/codegen-llvm/slp-vectorization-mul3.rs index 1c40c6b28f3ff..2987493e03713 100644 --- a/tests/codegen-llvm/slp-vectorization-mul3.rs +++ b/tests/codegen-llvm/slp-vectorization-mul3.rs @@ -1,6 +1,8 @@ //! Regression test for #142519 //@ only-x86_64 //@ compile-flags: -O +//@ min-llvm-version: 18.0 + #![crate_type = "lib"] From 61769452234deaf0e035789009ab807dd1ca93d4 Mon Sep 17 00:00:00 2001 From: ritik chahar Date: Mon, 2 Feb 2026 16:05:08 +0530 Subject: [PATCH 7/8] fix: remove space for tidy and only for x86_64 --- tests/codegen-llvm/slp-vectorization-mul3.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/codegen-llvm/slp-vectorization-mul3.rs b/tests/codegen-llvm/slp-vectorization-mul3.rs index 2987493e03713..d7c44c8db71a2 100644 --- a/tests/codegen-llvm/slp-vectorization-mul3.rs +++ b/tests/codegen-llvm/slp-vectorization-mul3.rs @@ -3,7 +3,6 @@ //@ compile-flags: -O //@ min-llvm-version: 18.0 - #![crate_type = "lib"] // CHECK-LABEL: @mul3 From 8476e893e72e1e3617fb50a06a01548d6177d192 Mon Sep 17 00:00:00 2001 From: Ritik Chahar <126174435+chahar-ritik@users.noreply.github.com> Date: Mon, 2 Feb 2026 16:47:09 +0530 Subject: [PATCH 8/8] Update min-llvm-version: 22 Co-authored-by: Nikita Popov --- tests/codegen-llvm/slp-vectorization-mul3.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/codegen-llvm/slp-vectorization-mul3.rs b/tests/codegen-llvm/slp-vectorization-mul3.rs index d7c44c8db71a2..38c0949b82713 100644 --- a/tests/codegen-llvm/slp-vectorization-mul3.rs +++ b/tests/codegen-llvm/slp-vectorization-mul3.rs @@ -1,7 +1,7 @@ //! Regression test for #142519 //@ only-x86_64 //@ compile-flags: -O -//@ min-llvm-version: 18.0 +//@ min-llvm-version: 22 #![crate_type = "lib"]