-
Enhancement
-
Resolution: Fixed
-
P4
-
22
-
b04
-
riscv
-
linux
Hi all,
We can use shadd to replace the following command combinations when appropriate:
```
slli(rd1, rs1, imm)
add(rd2, rs2, rs3)
```
Conditions to be met:
1. Rd1 and rs3/rs2 are the same register;
2. The data given to rd1 by the `slli` instruction is not used later;
3. Make sure rs2, rs3 are not the same register, so that the above instruction combination will actually be executed if zba is not enabled, whereas if rs2, rs3 are the same register then `slli` will destroy the value of rs3/rs2;
4. The value of `imm` is in the range of [1, 3], so that if zba is enabled, it will use sh1add, sh2add, sh3add instructions instead of the above two instructions.
We can use shadd to replace the following command combinations when appropriate:
```
slli(rd1, rs1, imm)
add(rd2, rs2, rs3)
```
Conditions to be met:
1. Rd1 and rs3/rs2 are the same register;
2. The data given to rd1 by the `slli` instruction is not used later;
3. Make sure rs2, rs3 are not the same register, so that the above instruction combination will actually be executed if zba is not enabled, whereas if rs2, rs3 are the same register then `slli` will destroy the value of rs3/rs2;
4. The value of `imm` is in the range of [1, 3], so that if zba is enabled, it will use sh1add, sh2add, sh3add instructions instead of the above two instructions.