From badc674ce4e77cd29645cd1cd9df5e57f47e08ae Mon Sep 17 00:00:00 2001
From: Michael Forney <mforney@mforney.org>
Date: Mon, 18 Oct 2021 10:41:49 -0700
Subject: qbe: Fix jnz controlled by short/char type

Although we don't need the cnew in this case, we still need to do
the appropriate extension to 32-bit.
---
 test/if-char.c   |  5 +++++
 test/if-char.qbe | 11 +++++++++++
 2 files changed, 16 insertions(+)
 create mode 100644 test/if-char.c
 create mode 100644 test/if-char.qbe

(limited to 'test')

diff --git a/test/if-char.c b/test/if-char.c
new file mode 100644
index 0000000..c22d767
--- /dev/null
+++ b/test/if-char.c
@@ -0,0 +1,5 @@
+int main(void) {
+	if ((unsigned char)0x100)
+		return 1;
+	return 0;
+}
diff --git a/test/if-char.qbe b/test/if-char.qbe
new file mode 100644
index 0000000..d964db4
--- /dev/null
+++ b/test/if-char.qbe
@@ -0,0 +1,11 @@
+export
+function w $main() {
+@start.1
+@body.2
+	%.1 =w extub 256
+	jnz %.1, @if_true.3, @if_false.4
+@if_true.3
+	ret 1
+@if_false.4
+	ret 0
+}
-- 
cgit v1.2.3