Skip to content

Commit 2d48e9f

Browse files
artemiy-volkovMichielDerhaeg
authored andcommitted
arcv: fuse load/store with lui
Fuse together instruction pairs such as: LOAD rd1, [rs1,offset] lui rd2, imm (where rd1 and rd2 are distinct) and: STORE rs2, [rs1,offset] lui rd, imm Signed-off-by: Artemiy Volkov <artemiy@synopsys.com>
1 parent a0e8c15 commit 2d48e9f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

gcc/config/riscv/riscv.cc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10538,6 +10538,22 @@ arcv_macro_fusion_pair_p (rtx_insn *prev, rtx_insn *curr)
1053810538
== REGNO (XEXP (SET_SRC (curr_set), 1))))))
1053910539
return true;
1054010540

10541+
/* Fuse load/store with lui:
10542+
* prev (ld) == (set (reg:X rd1) (mem:X (plus:X (reg:X) (const_int))))
10543+
* or
10544+
* prev (st) == (set (mem:X (plus:X (reg:X) (const_int))) (reg:X rD))
10545+
*
10546+
* curr (lui) == (set (reg:X rd2) (const_int UPPER_IMM_20))
10547+
*/
10548+
if (((get_attr_type (curr) == TYPE_MOVE
10549+
&& GET_CODE (SET_SRC (curr_set)) == HIGH)
10550+
|| (CONST_INT_P (SET_SRC (curr_set))
10551+
&& LUI_OPERAND (INTVAL (SET_SRC (curr_set)))))
10552+
&& ((get_attr_type (prev) == TYPE_LOAD
10553+
&& REGNO (SET_DEST (prev_set)) != REGNO (SET_DEST (curr_set)))
10554+
|| get_attr_type (prev) == TYPE_STORE))
10555+
return true;
10556+
1054110557
/* Fuse load-immediate with a store of the destination register. */
1054210558
if (get_attr_type (prev) == TYPE_MOVE
1054310559
&& get_attr_move_type (prev) == MOVE_TYPE_CONST

0 commit comments

Comments
 (0)