summary refs log tree commit diff
path: root/test
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin@c9x.me>2019-04-29 11:29:22 +0200
committerQuentin Carbonneaux <quentin@c9x.me>2019-04-29 12:01:54 +0200
commit660a8d9dfa44050897b2f5ead823554893d79f24 (patch)
treed24f77c684f7439c193bb6a7898fafad50eb48f3 /test
parent0384d73e8daa5c948fb08c7301144c0d7e740ef9 (diff)
downloadroux-660a8d9dfa44050897b2f5ead823554893d79f24.tar.gz
fix folding of unsigned operations
This fixes similar bugs than the ones fixed
in the previous commit.

In the folding code the invariant is that
when a result is 32 bits wide, the low 32
bits of 'x' are correct.  The high bits
can be anything.
Diffstat (limited to 'test')
-rw-r--r--test/fold1.ssa26
1 files changed, 24 insertions, 2 deletions
diff --git a/test/fold1.ssa b/test/fold1.ssa
index 0ee2f91..9fb5d71 100644
--- a/test/fold1.ssa
+++ b/test/fold1.ssa
@@ -19,7 +19,29 @@ function w $f3() {
 	ret %x
 }
 
+export
+function w $f4() {
+@start
+	%x =w shr 4294967296, 1  # 2^32 >> 1
+	ret %x
+}
+
+export
+function w $f5() {
+@start
+	%x =w udiv 1, 4294967297  # 1 / (2^32 + 1)
+	ret %x
+}
+
+export
+function w $f6() {
+@start
+	%x =w urem 4294967296, 7  # 2^32 % 7
+	ret %x
+}
+
 # >>> driver
-# extern int f1(), f2(), f3();
-# int main() { return !(f1() == -1 && f2() == -32 && f3() == -5); }
+# extern int f1(), f2(), f3(), f4(), f5(), f6();
+# int main() { return !(f1() == -1 && f2() == -32 && f3() == -5 &&
+#                       f4() == 0 && f5() == 1 && f6() == 0); }
 # <<<