Skip to content

Commit 348a703

Browse files
zifeihanRealFYang
authored andcommitted
8318953: RISC-V: Small refactoring for MacroAssembler::test_bit
Reviewed-by: fyang Backport-of: 988e1dfe6ec9b5e77d2e8a78eb792a127c6fe907
1 parent 594e5d7 commit 348a703

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

src/hotspot/cpu/riscv/macroAssembler_riscv.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -4518,11 +4518,17 @@ void MacroAssembler::cmp_l2i(Register dst, Register src1, Register src2, Registe
45184518
bind(done);
45194519
}
45204520

4521-
void MacroAssembler::test_bit(Register Rd, Register Rs, uint32_t bit_pos, Register tmp) {
4521+
void MacroAssembler::test_bit(Register Rd, Register Rs, uint32_t bit_pos) {
45224522
assert(bit_pos < 64, "invalid bit range");
45234523
if (UseZbs) {
45244524
bexti(Rd, Rs, bit_pos);
45254525
return;
45264526
}
4527-
andi(Rd, Rs, 1UL << bit_pos, tmp);
4527+
int64_t imm = (int64_t)(1UL << bit_pos);
4528+
if (is_simm12(imm)) {
4529+
and_imm12(Rd, Rs, imm);
4530+
} else {
4531+
srli(Rd, Rs, bit_pos);
4532+
and_imm12(Rd, Rd, 1);
4533+
}
45284534
}

src/hotspot/cpu/riscv/macroAssembler_riscv.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1144,7 +1144,7 @@ class MacroAssembler: public Assembler {
11441144
void shadd(Register Rd, Register Rs1, Register Rs2, Register tmp, int shamt);
11451145

11461146
// test single bit in Rs, result is set to Rd
1147-
void test_bit(Register Rd, Register Rs, uint32_t bit_pos, Register tmp = t0);
1147+
void test_bit(Register Rd, Register Rs, uint32_t bit_pos);
11481148

11491149
// Here the float instructions with safe deal with some exceptions.
11501150
// e.g. convert from NaN, +Inf, -Inf to int, float, double

src/hotspot/cpu/riscv/riscv.ad

+1-1
Original file line numberDiff line numberDiff line change
@@ -2318,7 +2318,7 @@ encode %{
23182318
if (DiagnoseSyncOnValueBasedClasses != 0) {
23192319
__ load_klass(flag, oop);
23202320
__ lwu(flag, Address(flag, Klass::access_flags_offset()));
2321-
__ test_bit(flag, flag, exact_log2(JVM_ACC_IS_VALUE_BASED_CLASS), tmp /* tmp */);
2321+
__ test_bit(flag, flag, exact_log2(JVM_ACC_IS_VALUE_BASED_CLASS));
23222322
__ bnez(flag, cont, true /* is_far */);
23232323
}
23242324

0 commit comments

Comments
 (0)