test_half_sign_needed is a negative test expecting a sign-extending
halfword load (lh).  With *p >> 8 on a 16-bit short only the high byte
is needed, so the compiler emits a sign-extending byte load (lb) and the
lh match fails.  Use *p >> 4 so the full halfword load is required.

gcc/testsuite/ChangeLog:

        * gcc.target/riscv/ext-dce-4.c (test_half_sign_needed): Shift
        by 4 instead of 8 to keep the lh load.
---
 gcc/testsuite/gcc.target/riscv/ext-dce-4.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.target/riscv/ext-dce-4.c 
b/gcc/testsuite/gcc.target/riscv/ext-dce-4.c
index 8a4f3637652..e7cb86d5c50 100644
--- a/gcc/testsuite/gcc.target/riscv/ext-dce-4.c
+++ b/gcc/testsuite/gcc.target/riscv/ext-dce-4.c
@@ -42,7 +42,7 @@ test_byte (signed char *p)
 int
 test_half_sign_needed (signed short *p)
 {
-  return *p >> 8;
+  return *p >> 4;
 }
 
 /*
-- 
2.52.0

Reply via email to