brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · e79d0b6 Raw
44 lines · plain
1// RUN:   mlir-opt %s -test-math-polynomial-approximation="enable-avx2"        \2// RUN:               -convert-vector-to-scf                                   \3// RUN:               -convert-scf-to-cf                                       \4// RUN:               -convert-arith-to-llvm                                   \5// RUN:               -convert-cf-to-llvm                                   \6// RUN:               -convert-vector-to-llvm="enable-x86vector"               \7// RUN:               -convert-math-to-llvm                                    \8// RUN:               -convert-func-to-llvm                                    \9// RUN:               -reconcile-unrealized-casts                              \10// RUN: | mlir-runner                                                      \11// RUN:     -e main -entry-point-result=void -O0                               \12// RUN:     -shared-libs=%mlir_c_runner_utils  \13// RUN:     -shared-libs=%mlir_runner_utils    \14// RUN: | FileCheck %s15 16// -------------------------------------------------------------------------- //17// rsqrt.18// -------------------------------------------------------------------------- //19 20func.func @rsqrt() {21  // Sanity-check that the scalar rsqrt still works OK.22  // CHECK: inf23  %0 = arith.constant 0.0 : f3224  %rsqrt_0 = math.rsqrt %0 : f3225  vector.print %rsqrt_0 : f3226  // CHECK: 0.70710727  %two = arith.constant 2.0: f3228  %rsqrt_two = math.rsqrt %two : f3229  vector.print %rsqrt_two : f3230 31  // Check that the vectorized approximation is reasonably accurate.32  // CHECK: 0.707107, 0.707107, 0.707107, 0.707107, 0.707107, 0.707107, 0.707107, 0.70710733  %vec8 = arith.constant dense<2.0> : vector<8xf32>34  %rsqrt_vec8 = math.rsqrt %vec8 : vector<8xf32>35  vector.print %rsqrt_vec8 : vector<8xf32>36 37  return38}39 40func.func @main() {41  call @rsqrt(): () -> ()42  return43}44