[clang] [llvm] [X86] EmitX86BuiltinExpr - attempt to convert SSE41/AVX1 roundps/d/ss/sd builtins to regular rounding modes (PR #171227)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 18 04:15:35 PST 2025


================
@@ -32,4 +32,27 @@ __m256d test_mm256_sqrt_pd(__m256d x) {
   // CONSTRAINED: call {{.*}}<4 x double> @llvm.experimental.constrained.sqrt.v4f64(<4 x double> {{.*}}, metadata !{{.*}})
   // CHECK-ASM: vsqrtpd %ymm{{.*}}, 
   return _mm256_sqrt_pd(x);
+}
+
+__m256d test_mm256_round_pd_dynamic(__m256d x) {
+  // CHECK-LABEL: test_mm256_round_pd_dynamic
+  // CHECK:  %{{.*}} = call <4 x double> @llvm.experimental.constrained.nearbyint.v4f64(<4 x double> %{{.*}}, metadata !"round.dynamic", metadata !"fpexcept.ignore")
+  return _mm256_round_pd(x, 8);
+}
+
+__m256d test_mm256_round_pd_trunc(__m256d x) {
+  // CHECK-LABEL: test_mm256_round_pd_trunc
+  // CHECK: %{{.*}} = call <4 x double> @llvm.experimental.constrained.trunc.v4f64(<4 x double> %{{.*}}, metadata !"fpexcept.ignore")
+  return _mm256_round_pd(x, 3);
+}
+
+__m256 test_mm256_round_ps_dynamic(__m256 x) {
+  // CHECK-LABEL: test_mm256_round_ps_dynamic
+  // CHECK: %{{.*}} = call <8 x float> @llvm.experimental.constrained.nearbyint.v8f32(<8 x float> %{{.*}}, metadata !"round.dynamic", metadata !"fpexcept.ignore")
+  return _mm256_round_ps(x, 8);
----------------
RKSimon wrote:

Broken MXCSR test?
```suggestion
  return _mm256_round_ps(x, 0x4);
```

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


More information about the llvm-commits mailing list