ir_ssa_test.cc 694 Bytes
Newer Older
tqchen committed
1 2 3 4 5
#include <dmlc/logging.h>
#include <gtest/gtest.h>
#include <tvm/tvm.h>
#include <tvm/ir_pass.h>

tqchen committed
6 7

TEST(IRSSA, Convert) {
8
  using namespace HalideIR::Internal;
tqchen committed
9 10 11 12
  using namespace tvm;
  Var x("x"), y;
  Expr let = Let::make(x, 1, x + 1);

tqchen committed
13
  auto z = Evaluate::make(let + let);
tqchen committed
14
  CHECK(!ir::VerifySSA(z));
tqchen committed
15
  auto z_ssa = ir::ConvertSSA(z);
tqchen committed
16 17 18 19
  CHECK(ir::VerifySSA(z_ssa));
}

TEST(IRSSA, Basic) {
20
  using namespace HalideIR::Internal;
tqchen committed
21 22
  using namespace tvm;
  Var x("x"), y;
tqchen committed
23
  auto z = Evaluate::make(x + y);
tqchen committed
24
  CHECK(ir::VerifySSA(z));
tqchen committed
25 26 27 28 29 30 31
}

int main(int argc, char ** argv) {
  testing::InitGoogleTest(&argc, argv);
  testing::FLAGS_gtest_death_test_style = "threadsafe";
  return RUN_ALL_TESTS();
}