8161190: AArch64: Fix overflow in immediate cmp instruction

Use subs instead of cmp to compare BlockZeroingLowLimit. Subs can check and handle immediate out of range correctly.

Reviewed-by: aph
This commit is contained in:
Yang Zhang 2016-07-22 17:05:08 +01:00 committed by Andrew Haley
parent 48476abaa6
commit cabbc68c64
2 changed files with 3 additions and 2 deletions

View file

@ -4916,7 +4916,7 @@ void MacroAssembler::block_zero(Register base, Register cnt, bool is_large)
// alignment. // alignment.
if (!is_large || !(BlockZeroingLowLimit >= zva_length * 2)) { if (!is_large || !(BlockZeroingLowLimit >= zva_length * 2)) {
int low_limit = MAX2(zva_length * 2, (int)BlockZeroingLowLimit); int low_limit = MAX2(zva_length * 2, (int)BlockZeroingLowLimit);
cmp(cnt, low_limit >> 3); subs(tmp, cnt, low_limit >> 3);
br(Assembler::LT, small); br(Assembler::LT, small);
} }

View file

@ -2346,8 +2346,9 @@ class StubGenerator: public StubCodeGenerator {
__ subw(count, count, cnt_words, Assembler::LSL, 3 - shift); __ subw(count, count, cnt_words, Assembler::LSL, 3 - shift);
if (UseBlockZeroing) { if (UseBlockZeroing) {
Label non_block_zeroing, rest; Label non_block_zeroing, rest;
Register tmp = rscratch1;
// count >= BlockZeroingLowLimit && value == 0 // count >= BlockZeroingLowLimit && value == 0
__ cmp(cnt_words, BlockZeroingLowLimit >> 3); __ subs(tmp, cnt_words, BlockZeroingLowLimit >> 3);
__ ccmp(value, 0 /* comparing value */, 0 /* NZCV */, Assembler::GE); __ ccmp(value, 0 /* comparing value */, 0 /* NZCV */, Assembler::GE);
__ br(Assembler::NE, non_block_zeroing); __ br(Assembler::NE, non_block_zeroing);
__ mov(bz_base, to); __ mov(bz_base, to);