From 95e7964b41c371d619f504a3d46b4976f86f5b55 Mon Sep 17 00:00:00 2001
From: Peter Trommler <ptrommler@acm.org>
Date: Wed, 5 Jan 2022 19:17:03 +0100
Subject: [PATCH] Fix T20638 on big-endian architectures

The test reads a 16 bit value from an array of 8 bit values. Naturally,
that leads to different values read on big-endian architectures than
on little-endian. In this case the value read is 0x8081 on big-endian
and 0x8180 on little endian. This patch changes the argument of the `and`
machop to mask bit 7 which is the only bit different. The test still checks
that bit 15 is zero, which was the original issue in #20638.

Fixes #20906.
---
 testsuite/tests/cmm/should_run/machops/T20638.cmm    | 2 +-
 testsuite/tests/cmm/should_run/machops/T20638.stdout | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/testsuite/tests/cmm/should_run/machops/T20638.cmm b/testsuite/tests/cmm/should_run/machops/T20638.cmm
index 51fe449a767b..64835b7584aa 100644
--- a/testsuite/tests/cmm/should_run/machops/T20638.cmm
+++ b/testsuite/tests/cmm/should_run/machops/T20638.cmm
@@ -1,4 +1,4 @@
 test(bits64 buffer) {
-  return (%zx64(%shrl(bits16[buffer + (128 :: bits64)], (1 :: bits64))) & (64711 :: bits64));
+  return (%zx64(%shrl(bits16[buffer + (128 :: bits64)], (1 :: bits64))) & (65407 :: bits64));
 }
 
diff --git a/testsuite/tests/cmm/should_run/machops/T20638.stdout b/testsuite/tests/cmm/should_run/machops/T20638.stdout
index 5a5484290252..81669a372473 100644
--- a/testsuite/tests/cmm/should_run/machops/T20638.stdout
+++ b/testsuite/tests/cmm/should_run/machops/T20638.stdout
@@ -1 +1 @@
-16576
+16448
-- 
GitLab