From e497947ec34512d57dd5fb3a0e24871c7c97337e Mon Sep 17 00:00:00 2001 From: kohsine Date: Thu, 11 Jun 2026 17:31:39 -0400 Subject: [PATCH] Add regression test for pclmulqdq inlining across target feature --- .../pclmulqdq-target-feature-inlining.rs | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tests/codegen-llvm/pclmulqdq-target-feature-inlining.rs diff --git a/tests/codegen-llvm/pclmulqdq-target-feature-inlining.rs b/tests/codegen-llvm/pclmulqdq-target-feature-inlining.rs new file mode 100644 index 0000000000000..d0ae15a597696 --- /dev/null +++ b/tests/codegen-llvm/pclmulqdq-target-feature-inlining.rs @@ -0,0 +1,29 @@ +//@ only-x86_64 +//@ compile-flags: -C opt-level=3 + +//! Regression test for https://github.com/rust-lang/rust/issues/139029 +//! +//! pclmulqdq intrinsics should inline across target_feature + +#![crate_type = "lib"] + +use std::arch::x86_64 as arch; + +// CHECK-LABEL: @reduce128_caller +// CHECK: call <2 x i64> @llvm.x86.pclmulqdq +// CHECK: call <2 x i64> @llvm.x86.pclmulqdq +#[target_feature(enable = "pclmulqdq", enable = "sse2", enable = "sse4.1")] +#[no_mangle] +pub unsafe fn reduce128_caller( + a: arch::__m128i, + b: arch::__m128i, + keys: arch::__m128i, +) -> arch::__m128i { + reduce128(a, b, keys) +} + +unsafe fn reduce128(a: arch::__m128i, b: arch::__m128i, keys: arch::__m128i) -> arch::__m128i { + let t1 = arch::_mm_clmulepi64_si128(a, keys, 0x00); + let t2 = arch::_mm_clmulepi64_si128(a, keys, 0x11); + arch::_mm_xor_si128(arch::_mm_xor_si128(b, t1), t2) +}