summaryrefslogtreecommitdiff
path: root/test/example/c-api-kitchen-sink.c
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-05-05 11:47:54 -0700
committerAlon Zakai <alonzakai@gmail.com>2016-05-05 11:47:54 -0700
commitbb3dbb2784e91a517916f366e710e01a2e7331f6 (patch)
tree08ee1e92384235c2f830b65ba7a12c59689d1b88 /test/example/c-api-kitchen-sink.c
parentf85e310924535da09822f3d43aeee9265eb12760 (diff)
parentbbf846554a407e0385f91f5b7eeb9594c12e0bc5 (diff)
downloadbinaryen-bb3dbb2784e91a517916f366e710e01a2e7331f6.tar.gz
binaryen-bb3dbb2784e91a517916f366e710e01a2e7331f6.tar.bz2
binaryen-bb3dbb2784e91a517916f366e710e01a2e7331f6.zip
Merge pull request #435 from WebAssembly/more-relooper
Add optimization to C API, and with that, more relooper tests
Diffstat (limited to 'test/example/c-api-kitchen-sink.c')
-rw-r--r--test/example/c-api-kitchen-sink.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/example/c-api-kitchen-sink.c b/test/example/c-api-kitchen-sink.c
index 28fd901a4..b7b938c55 100644
--- a/test/example/c-api-kitchen-sink.c
+++ b/test/example/c-api-kitchen-sink.c
@@ -332,8 +332,35 @@ void test_relooper() {
BinaryenExpressionRef body = RelooperRenderAndDispose(relooper, block0, 0, module);
BinaryenFunctionRef sinker = BinaryenAddFunction(module, "loop-tail", v, localTypes, 1, body);
}
+ { // nontrivial loop + phi to head
+ RelooperRef relooper = RelooperCreate();
+ RelooperBlockRef block0 = RelooperAddBlock(relooper, makeInt32(module, 0));
+ RelooperBlockRef block1 = RelooperAddBlock(relooper, makeInt32(module, 1));
+ RelooperBlockRef block2 = RelooperAddBlock(relooper, makeInt32(module, 2));
+ RelooperBlockRef block3 = RelooperAddBlock(relooper, makeInt32(module, 3));
+ RelooperBlockRef block4 = RelooperAddBlock(relooper, makeInt32(module, 4));
+ RelooperBlockRef block5 = RelooperAddBlock(relooper, makeInt32(module, 5));
+ RelooperBlockRef block6 = RelooperAddBlock(relooper, makeInt32(module, 6));
+ RelooperAddBranch(block0, block1, NULL, makeInt32(module, 10));
+ RelooperAddBranch(block1, block2, makeInt32(module, -2), NULL);
+ RelooperAddBranch(block1, block6, NULL, makeInt32(module, 20));
+ RelooperAddBranch(block2, block3, makeInt32(module, -6), NULL);
+ RelooperAddBranch(block2, block1, NULL, makeInt32(module, 30));
+ RelooperAddBranch(block3, block4, makeInt32(module, -10), NULL);
+ RelooperAddBranch(block3, block5, NULL, NULL);
+ RelooperAddBranch(block4, block5, NULL, NULL);
+ RelooperAddBranch(block5, block6, NULL, makeInt32(module, 40));
+ BinaryenExpressionRef body = RelooperRenderAndDispose(relooper, block0, 0, module);
+ BinaryenFunctionRef sinker = BinaryenAddFunction(module, "nontrivial-loop-plus-phi-to-head", v, localTypes, 1, body);
+ }
+ printf("raw:\n");
BinaryenModulePrint(module);
+
+ printf("optimized:\n");
+ BinaryenModuleOptimize(module);
+ BinaryenModulePrint(module);
+
BinaryenModuleDispose(module);
}