aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/bitfield-assignment-sign-extend.c6
-rw-r--r--test/bitfield-assignment-sign-extend.qbe21
-rw-r--r--test/bitfield-compound-assign.qbe12
3 files changed, 34 insertions, 5 deletions
diff --git a/test/bitfield-assignment-sign-extend.c b/test/bitfield-assignment-sign-extend.c
new file mode 100644
index 0000000..f466881
--- /dev/null
+++ b/test/bitfield-assignment-sign-extend.c
@@ -0,0 +1,6 @@
+struct {
+ signed x : 4;
+} s;
+int main(void) {
+ return (s.x = 15) != -1;
+}
diff --git a/test/bitfield-assignment-sign-extend.qbe b/test/bitfield-assignment-sign-extend.qbe
new file mode 100644
index 0000000..05ffbf9
--- /dev/null
+++ b/test/bitfield-assignment-sign-extend.qbe
@@ -0,0 +1,21 @@
+export
+function w $main() {
+@start.1
+@body.2
+ %.1 =l copy $s
+ %.2 =l mul 0, 1
+ %.3 =l add %.1, %.2
+ %.4 =l copy %.3
+ %.5 =w shl 15, 0
+ %.6 =w shl %.5, 28
+ %.7 =w sar %.6, 28
+ %.8 =w and %.5, 15
+ %.9 =w loaduw %.4
+ %.10 =w and %.9, 18446744073709551600
+ %.11 =w or %.8, %.10
+ storew %.11, %.4
+ %.12 =w sub 0, 1
+ %.13 =w cnew %.7, %.12
+ ret %.13
+}
+export data $s = align 4 { z 4 }
diff --git a/test/bitfield-compound-assign.qbe b/test/bitfield-compound-assign.qbe
index 5cc38de..8e08ff6 100644
--- a/test/bitfield-compound-assign.qbe
+++ b/test/bitfield-compound-assign.qbe
@@ -11,11 +11,13 @@ function $f() {
%.7 =w sar %.6, 23
%.8 =w add %.7, 3
%.9 =w shl %.8, 4
- %.10 =w and %.9, 8176
- %.11 =w loaduw %.4
- %.12 =w and %.11, 18446744073709543439
- %.13 =w or %.10, %.12
- storew %.13, %.4
+ %.10 =w shl %.9, 19
+ %.11 =w sar %.10, 23
+ %.12 =w and %.9, 8176
+ %.13 =w loaduw %.4
+ %.14 =w and %.13, 18446744073709543439
+ %.15 =w or %.12, %.14
+ storew %.15, %.4
ret
}
export data $s = align 4 { z 4 }