Skip to content

Commit e7e75c5

Browse files
[RISC-V] Add pseudo instruction not and replace xori when immediate is -1 (#117967)
* [RISC-V] Add pseudo instruction not * [RISC-V] emit not * [RISC-V] Replace xori with not when immediate is -1
1 parent 8083ecc commit e7e75c5

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

src/coreclr/jit/codegenriscv64.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,7 @@ void CodeGen::genCodeForIncSaturate(GenTree* tree)
10091009
GetEmitter()->emitIns_R_R_I(INS_addi, attr, targetReg, operandReg, 1);
10101010
// bne targetReg, zero, 2 * 4
10111011
GetEmitter()->emitIns_R_R_I(INS_bne, attr, targetReg, REG_R0, 8);
1012-
GetEmitter()->emitIns_R_R_I(INS_xori, attr, targetReg, targetReg, -1);
1012+
GetEmitter()->emitIns_R_R(INS_not, attr, targetReg, targetReg);
10131013

10141014
genProduceReg(tree);
10151015
}
@@ -1691,7 +1691,7 @@ void CodeGen::genCodeForNegNot(GenTree* tree)
16911691
else if (tree->OperIs(GT_NOT))
16921692
{
16931693
assert(!varTypeIsFloating(targetType));
1694-
GetEmitter()->emitIns_R_R_I(INS_xori, attr, targetReg, operandReg, -1);
1694+
GetEmitter()->emitIns_R_R(INS_not, attr, targetReg, operandReg);
16951695
}
16961696

16971697
genProduceReg(tree);

src/coreclr/jit/emitriscv64.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ void emitter::emitIns_R_R(
650650
{
651651
code_t code = emitInsCode(ins);
652652

653-
if (INS_mov == ins || INS_sext_w == ins || (INS_clz <= ins && ins <= INS_rev8))
653+
if (INS_mov == ins || INS_sext_w == ins || INS_not == ins || (INS_clz <= ins && ins <= INS_rev8))
654654
{
655655
assert(isGeneralRegisterOrR0(reg1));
656656
assert(isGeneralRegisterOrR0(reg2));

src/coreclr/jit/instrsriscv64.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ INST(nop, "nop", 0, 0x00000013)
3737
//// R_R
3838
INST(mov, "mv", 0, 0x00000013)
3939
INST(sext_w, "sext.w", 0, 0x0000001b)
40+
INST(not, "not", 0, 0xFFF04013)
4041

4142
////R_I
4243
INST(lui, "lui", 0, 0x00000037)

0 commit comments

Comments
 (0)