1 // RUN: mlir-opt %s -test-math-polynomial-approximation="enable-avx2" \
2 // RUN: -convert-arith-to-llvm \
3 // RUN: -convert-vector-to-llvm="enable-x86vector" \
4 // RUN: -convert-math-to-llvm \
5 // RUN: -convert-std-to-llvm \
6 // RUN: -reconcile-unrealized-casts \
7 // RUN: | mlir-cpu-runner \
8 // RUN: -e main -entry-point-result=void -O0 \
9 // RUN: -shared-libs=%linalg_test_lib_dir/libmlir_c_runner_utils%shlibext \
10 // RUN: -shared-libs=%linalg_test_lib_dir/libmlir_runner_utils%shlibext \
11 // RUN: | FileCheck %s
13 // -------------------------------------------------------------------------- //
15 // -------------------------------------------------------------------------- //
18 // Sanity-check that the scalar rsqrt still works OK.
20 %0 = arith.constant 0.0 : f32
21 %rsqrt_0 = math.rsqrt %0 : f32
22 vector.print %rsqrt_0 : f32
24 %two = arith.constant 2.0: f32
25 %rsqrt_two = math.rsqrt %two : f32
26 vector.print %rsqrt_two : f32
28 // Check that the vectorized approximation is reasonably accurate.
29 // CHECK: 0.707107, 0.707107, 0.707107, 0.707107, 0.707107, 0.707107, 0.707107, 0.707107
30 %vec8 = arith.constant dense<2.0> : vector<8xf32>
31 %rsqrt_vec8 = math.rsqrt %vec8 : vector<8xf32>
32 vector.print %rsqrt_vec8 : vector<8xf32>
38 call @rsqrt(): () -> ()