- test sqrt
  - impl. sqrt for llvm

Change-Id: I38a06ee57bf4d50e7d068321ab765ede3d1d73bc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/274183
Commit-Queue: Mike Klein <mtklein@google.com>
Commit-Queue: Herb Derby <herb@google.com>
Reviewed-by: Herb Derby <herb@google.com>
This commit is contained in:
Mike Klein 2020-02-28 14:24:56 -06:00 committed by Skia Commit-Bot
parent 83346185be
commit 5a8404c93e
2 changed files with 30 additions and 0 deletions

View File

@ -2072,6 +2072,10 @@ namespace skvm {
vals[i] = I(b->CreateUnaryIntrinsic(llvm::Intrinsic::floor, F(vals[x])));
break;
case Op::sqrt_f32:
vals[i] = I(b->CreateUnaryIntrinsic(llvm::Intrinsic::sqrt, F(vals[x])));
break;
case Op::to_f32: vals[i] = I(b->CreateSIToFP( vals[x] , F32)); break;
case Op::trunc : vals[i] = b->CreateFPToSI(F(vals[x]), I32) ; break;

View File

@ -887,6 +887,32 @@ DEF_TEST(SkVM_NewOps, r) {
});
}
DEF_TEST(SkVM_sqrt, r) {
skvm::Builder b;
auto buf = b.varying<int>();
b.store32(buf, b.bit_cast(b.sqrt(b.bit_cast(b.load32(buf)))));
#if defined(SKVM_LLVM) || defined(SK_CPU_X86)
test_jit_and_interpreter
#else
test_interpreter_only
#endif
(r, b.done(), [&](const skvm::Program& program) {
constexpr int K = 17;
float buf[K];
for (int i = 0; i < K; i++) {
buf[i] = (float)(i*i);
}
// x^2 -> x
program.eval(K, buf);
for (int i = 0; i < K; i++) {
REPORTER_ASSERT(r, buf[i] == (float)i);
}
});
}
DEF_TEST(SkVM_MSAN, r) {
// This little memset32() program should be able to JIT, but if we run that
// JIT code in an MSAN build, it won't see the writes initialize buf. So