From aee4b02ecdca43d66f4e0e4acc961e6efff56a6f Mon Sep 17 00:00:00 2001 From: Martin Doerr Date: Mon, 23 Feb 2026 13:00:00 +0000 Subject: [PATCH] 8378353: [PPC64] StringCoding.countPositives causes errors when the length is not a proper 32 bit int Reviewed-by: mbaesken, dbriemann --- src/hotspot/cpu/ppc/c2_MacroAssembler_ppc.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/hotspot/cpu/ppc/c2_MacroAssembler_ppc.cpp b/src/hotspot/cpu/ppc/c2_MacroAssembler_ppc.cpp index 73b6b132895..2d5071ce86d 100644 --- a/src/hotspot/cpu/ppc/c2_MacroAssembler_ppc.cpp +++ b/src/hotspot/cpu/ppc/c2_MacroAssembler_ppc.cpp @@ -600,19 +600,21 @@ void C2_MacroAssembler::count_positives(Register src, Register cnt, Register res orr(tmp0, tmp2, tmp0); and_(tmp0, tmp0, tmp1); - bne(CR0, Lslow); // Found negative byte. + bne(CR0, Lslow); // Found negative byte. addi(result, result, 16); bdnz(Lfastloop); 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(CR0, Ldone); mtctr(tmp0); + bind(Lloop); lbz(tmp0, 0, result); andi_(tmp0, tmp0, 0x80); - bne(CR0, Ldone); // Found negative byte. + bne(CR0, Ldone); // Found negative byte. addi(result, result, 1); bdnz(Lloop);