We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2bf196d commit 28e4327Copy full SHA for 28e4327
src/riscv-codegen.c
@@ -443,20 +443,20 @@ void emit_ph2_ir(ph2_ir_t *ph2_ir)
443
case OP_sign_ext:
444
if (ph2_ir->src1 == 1) {
445
/* Sign extend from byte to word */
446
- emit(__andi(rd, rs1, 0xFF));
447
- emit(__slli(rd, rd, 24));
448
- emit(__srai(rd, rd, 24));
+ rs2 = 0xFF;
+ ofs = 24;
449
} else if (ph2_ir->src1 == 2) {
450
/* Sign extend from short to word */
451
- emit(__andi(rd, rs1, 0xFFFF));
452
- emit(__slli(rd, rd, 16)); /* Shift left 16 bits */
453
- emit(__srai(rd, rd, 16)); /* Arithmetic shift right 16 bits */
+ rs2 = 0xFFFF;
+ ofs = 16;
454
} else {
455
/* Fallback to original behavior for unknown sizes */
456
457
458
459
}
+ emit(__andi(rd, rs1, rs2));
+ emit(__slli(rd, rd, ofs));
+ emit(__srai(rd, rd, ofs));
460
return;
461
case OP_cast:
462
/* Generic cast operation - for now, just move the value */
0 commit comments