-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The bitfield zero_extract operation is normally expanded into an srai followed by an andi. (With the ZBS extension enabled, the special case of 1-bit zero-extract is implemented with the bexti insn.) However, since the RHX core can execute a shift-left and a shift-right of the same register in 1 cycle, we would prefer to emit those two instructions instead, and schedule them together so that macro fusion can take place. The required steps to achieve this are: (1) Create an insn_and_split that handles the zero_extract RTX; (2) Tell the combiner to use that split by lowering the cost of the zero_extract RTX when the target is the RHX core; (3) Designate the resulting slli + srli pair as fusable by the scheduler. Attached is a small testcase demonstrating the split, and that the bexti insn still takes priority over the shift pair. Signed-off-by: Artemiy Volkov <artemiy@synopsys.com>
- Loading branch information
1 parent
654efd4
commit 2677e8b
Showing
3 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* { dg-do compile } */ | ||
/* { dg-require-effective-target rv32 } */ | ||
/* { dg-skip-if "" { *-*-* } { "-g" "-flto" "-O0" "-Oz" "-Os" } } */ | ||
/* { dg-options "-mtune=rhx -march=rv32im_zbs -mabi=ilp32" } */ | ||
|
||
#define bit_extract(x,start,amt) (((x)>>(start)) & (~(0xffffffff << (amt)))) | ||
|
||
int | ||
f (int x) | ||
{ | ||
return bit_extract(x,10,14) + bit_extract(x,1,1); | ||
} | ||
|
||
/* { dg-final { scan-assembler {\sslli\s([ast][0-9]+),a0,8\n\ssrli\s\1,\1,18\n\sbexti\sa0,a0,1\n\sadd\sa0,\1,a0\n} } } */ |