From b003f0fe485a4c6676749d6ed66db3652bfbda22 Mon Sep 17 00:00:00 2001 From: Martin Doerr Date: Sat, 7 Mar 2026 19:52:00 +0000 Subject: [PATCH] 8378353: [PPC64] StringCoding.countPositives causes errors when the length is not a proper 32 bit int Reviewed-by: mbaesken Backport-of: aee4b02ecdca43d66f4e0e4acc961e6efff56a6f --- src/hotspot/cpu/ppc/c2_MacroAssembler_ppc.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/hotspot/cpu/ppc/c2_MacroAssembler_ppc.cpp b/src/hotspot/cpu/ppc/c2_MacroAssembler_ppc.cpp index d504c71e2b8b..608f8f919463 100644 --- a/src/hotspot/cpu/ppc/c2_MacroAssembler_ppc.cpp +++ b/src/hotspot/cpu/ppc/c2_MacroAssembler_ppc.cpp @@ -594,9 +594,11 @@ void C2_MacroAssembler::count_positives(Register src, Register cnt, Register res bind(Lslow); // Fallback to slow version. subf(tmp0, src, result); // Bytes known positive. - subf_(tmp0, tmp0, cnt); // Remaining Bytes. + clrldi(tmp1, cnt, 32); // Clear garbage from upper 32 bits. + subf_(tmp0, tmp0, tmp1); // Remaining Bytes. beq(CCR0, Ldone); mtctr(tmp0); + bind(Lloop); lbz(tmp0, 0, result); andi_(tmp0, tmp0, 0x80);