summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMax Graey <maxgraey@gmail.com>2021-06-03 23:22:30 +0300
committerGitHub <noreply@github.com>2021-06-03 13:22:30 -0700
commita4ab1c7ee7376977ca09e2d3c4358893e9fdfce2 (patch)
treeb8bb89becfd8ca853594a09456342024f92d2c52 /test
parenta440c7697875e5fcc046370b40295f6dffe44ee0 (diff)
downloadbinaryen-a4ab1c7ee7376977ca09e2d3c4358893e9fdfce2.tar.gz
binaryen-a4ab1c7ee7376977ca09e2d3c4358893e9fdfce2.tar.bz2
binaryen-a4ab1c7ee7376977ca09e2d3c4358893e9fdfce2.zip
[OptimizeInstructions] Handle post-MVP sign extended operations (#3910)
fixes part of #3906
Diffstat (limited to 'test')
-rw-r--r--test/example/cpp-unit.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/test/example/cpp-unit.cpp b/test/example/cpp-unit.cpp
index 3ab35d381..2c9b43de2 100644
--- a/test/example/cpp-unit.cpp
+++ b/test/example/cpp-unit.cpp
@@ -538,6 +538,56 @@ void test_bits() {
c0.value = Literal(int64_t(-1));
assert_equal(getMaxBits(&u), 32);
+ u.type = Type::i32;
+ c0.type = Type::i32;
+
+ u.op = ExtendS8Int32;
+ c0.value = Literal(int8_t(0));
+ assert_equal(getMaxBits(&u), 0);
+ c0.value = Literal(int8_t(127));
+ assert_equal(getMaxBits(&u), 7);
+ c0.value = Literal(int8_t(128));
+ assert_equal(getMaxBits(&u), 32);
+
+ u.op = ExtendS16Int32;
+ c0.value = Literal(int16_t(0));
+ assert_equal(getMaxBits(&u), 0);
+ c0.value = Literal(int16_t(0x7FFF));
+ assert_equal(getMaxBits(&u), 15);
+ c0.value = Literal(int16_t(0x8000));
+ assert_equal(getMaxBits(&u), 32);
+
+ u.type = Type::i64;
+ c0.type = Type::i32;
+
+ u.op = ExtendS8Int64;
+ c0.value = Literal(int8_t(0));
+ assert_equal(getMaxBits(&u), 0);
+ c0.value = Literal(int8_t(127));
+ assert_equal(getMaxBits(&u), 7);
+ c0.value = Literal(int8_t(128));
+ assert_equal(getMaxBits(&u), 64);
+
+ u.op = ExtendS16Int64;
+ c0.value = Literal(int16_t(0));
+ assert_equal(getMaxBits(&u), 0);
+ c0.value = Literal(int16_t(0x7FFF));
+ assert_equal(getMaxBits(&u), 15);
+ c0.value = Literal(int16_t(0x8000));
+ assert_equal(getMaxBits(&u), 64);
+
+ u.type = Type::i64;
+ c0.type = Type::i64;
+
+ u.op = ExtendS32Int64;
+ c0.value = Literal(int64_t(0));
+ assert_equal(getMaxBits(&u), 0);
+ c0.value = Literal(int64_t(0x7FFFFFFFLL));
+ assert_equal(getMaxBits(&u), 31);
+ c0.value = Literal(int64_t(0xFFFFFFFFLL));
+ assert_equal(getMaxBits(&u), 64);
+ c0.value = Literal(int64_t(-1LL));
+ assert_equal(getMaxBits(&u), 64);
}
void test_cost() {