summary refs log tree commit diff
path: root/test
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2019-04-27 12:22:57 -0700
committerQuentin Carbonneaux <quentin@c9x.me>2019-04-29 11:04:34 +0200
commit0384d73e8daa5c948fb08c7301144c0d7e740ef9 (patch)
treed79f696c8c91e9bcc60883b86a270bfb25b20263 /test
parente2bc0ad3960769ba7a0f1223ac160b0d985fff35 (diff)
downloadroux-0384d73e8daa5c948fb08c7301144c0d7e740ef9.tar.gz
fold: Make sure 32-bit constants get sign extended when necessary
Diffstat (limited to 'test')
-rw-r--r--test/fold1.ssa25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/fold1.ssa b/test/fold1.ssa
new file mode 100644
index 0000000..0ee2f91
--- /dev/null
+++ b/test/fold1.ssa
@@ -0,0 +1,25 @@
+export
+function w $f1() {
+@start
+	%x =w sar 2147483648, 31
+	ret %x
+}
+
+export
+function w $f2() {
+@start
+	%x =w div 4294967040, 8  # -256 / 8
+	ret %x
+}
+
+export
+function w $f3() {
+@start
+	%x =w rem 4294967284, 7  # -12 % 7
+	ret %x
+}
+
+# >>> driver
+# extern int f1(), f2(), f3();
+# int main() { return !(f1() == -1 && f2() == -32 && f3() == -5); }
+# <<<