From d036c4aaae7d23aaee05f9e947772367239a4072 Mon Sep 17 00:00:00 2001 From: Alex Volkov Date: Fri, 20 Mar 2026 19:51:55 -0400 Subject: [PATCH] Minimal test for issue #2947 --- test/val/bug2947.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 test/val/bug2947.c diff --git a/test/val/bug2947.c b/test/val/bug2947.c new file mode 100644 index 000000000..dbb479f2c --- /dev/null +++ b/test/val/bug2947.c @@ -0,0 +1,22 @@ + +/* bug #2947: Opt_a_tosbitwise() attempts to remove non-removable Rhs X */ + +#include +#include + +unsigned char a, b = 0; +unsigned char c = 10; +unsigned char d = 1; + +int main(void) { + /* 'if' needed to produce a label below, moved by OptJumpTarget3 */ + if (b != 0) { + /* Operation not important; it only affects the removal of one LDX #$00 */ + b = 0; + } + + /* d >= 0 is const, A/X=1 (Warning: Result of comparison is always true) */ + a = c ^ (d >= 0); + + return !(a == 11); +}