Skip to content

Commit 6eaebec

Browse files
committed
check first byte earlier
1 parent 165cfdd commit 6eaebec

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

runtime/compiler/p/codegen/J9TreeEvaluator.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11747,11 +11747,6 @@ static TR::Register *inlineStringCodingHasNegativesOrCountPositives(TR::Node *no
1174711747
TR::Compiler->om.contiguousArrayHeaderSizeInBytes());
1174811748
}
1174911749

11750-
// get the starting address
11751-
generateTrg1Src2Instruction(cg, TR::InstOpCode::add, node, startReg, startReg, indexReg);
11752-
// make the index 0 since everything we need is relative to the offset
11753-
generateTrg1ImmInstruction(cg, TR::InstOpCode::li, node, indexReg, 0);
11754-
1175511750
// check the first byte
1175611751
generateTrg1MemInstruction(cg, TR::InstOpCode::lbzx, node, tempReg,
1175711752
TR::MemoryReference::createWithIndexReg(cg, startReg, indexReg, 1));
@@ -11762,6 +11757,9 @@ static TR::Register *inlineStringCodingHasNegativesOrCountPositives(TR::Node *no
1176211757
else // when seeking negatives, we need to return 1
1176311758
generateConditionalBranchInstruction(cg, TR::InstOpCode::blt, node, matchLabel, cr6);
1176411759

11760+
// count from the offset position since we are supposed to return (index-offset)
11761+
generateTrg1Src2Instruction(cg, TR::InstOpCode::add, node, startReg, startReg, indexReg);
11762+
generateTrg1ImmInstruction(cg, TR::InstOpCode::li, node, indexReg, 1);
1176511763
// if we only have one byte end it here, and return 0 for hasNegative
1176611764
generateTrg1Src1ImmInstruction(cg, TR::InstOpCode::addi, node, indexReg, indexReg, 1);
1176711765
generateTrg1Src2Instruction(cg, TR::InstOpCode::cmp4, node, cr6, indexReg, lengthReg);

0 commit comments

Comments
 (0)