Skip to content

Commit b6d6136

Browse files
authored
Rollup merge of rust-lang#145001 - lucarlig:139029, r=nikic
regression test for intrinsics may not inline properly on pclmulqdq https://rust.godbolt.org/z/dWsa9ET99 Fixes rust-lang#139029
2 parents 617e078 + 988fc57 commit b6d6136

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Test for pclmulqdq intrinsics inlining across target_feature boundaries
2+
// Issue: https://github.com/rust-lang/rust/issues/139029
3+
//
4+
// When a function with target_feature calls another function without matching
5+
// target_feature attributes, the intrinsics may not inline properly, leading
6+
// to function calls instead of direct instructions.
7+
8+
//@ only-x86_64
9+
//@ compile-flags: -C opt-level=3
10+
11+
#![crate_type = "lib"]
12+
13+
use std::arch::x86_64 as arch;
14+
15+
// CHECK-LABEL: @reduce128_caller
16+
// CHECK-NOT: call
17+
// CHECK: call <2 x i64> @llvm.x86.pclmulqdq
18+
// CHECK: call <2 x i64> @llvm.x86.pclmulqdq
19+
// CHECK-NOT: call
20+
#[target_feature(enable = "pclmulqdq", enable = "sse2", enable = "sse4.1")]
21+
#[no_mangle]
22+
pub unsafe fn reduce128_caller(
23+
a: arch::__m128i,
24+
b: arch::__m128i,
25+
keys: arch::__m128i,
26+
) -> arch::__m128i {
27+
reduce128(a, b, keys)
28+
}
29+
30+
unsafe fn reduce128(a: arch::__m128i, b: arch::__m128i, keys: arch::__m128i) -> arch::__m128i {
31+
let t1 = arch::_mm_clmulepi64_si128(a, keys, 0x00);
32+
let t2 = arch::_mm_clmulepi64_si128(a, keys, 0x11);
33+
arch::_mm_xor_si128(arch::_mm_xor_si128(b, t1), t2)
34+
}

0 commit comments

Comments
 (0)