]> git.ipfire.org Git - thirdparty/gcc.git/commit
RISC-V: Optimize TARGET_XTHEADCONDMOV
authorDie Li <lidie@eswincomputing.com>
Mon, 29 May 2023 17:10:32 +0000 (11:10 -0600)
committerJeff Law <jlaw@ventanamicro.com>
Mon, 29 May 2023 17:11:46 +0000 (11:11 -0600)
commita1806f0918c0d3612c99b6193b9703d4b4c82c21
treede05f78b34b20e9b2a0782b6d09884498969529c
parent3c1e2b76e0f44a3a149dae8d803b03214025fd5e
RISC-V: Optimize TARGET_XTHEADCONDMOV

This patch allows less instructions to be used when TARGET_XTHEADCONDMOV is enabled.

Provide an example from the existing testcases.

Testcase:
int ConEmv_imm_imm_reg(int x, int y){
  if (x == 1000) return 10;
  return y;
}

Cflags:
-O2 -march=rv64gc_xtheadcondmov -mabi=lp64d

before patch:
ConEmv_imm_imm_reg:
addi a5,a0,-1000
li a0,10
th.mvnez a0,zero,a5
th.mveqz a1,zero,a5
or a0,a0,a1
ret

after patch:
ConEmv_imm_imm_reg:
addi a5,a0,-1000
li a0,10
th.mvnez a0,a1,a5
ret

Signed-off-by: Die Li <lidie@eswincomputing.com>
gcc/ChangeLog:

* config/riscv/riscv.cc (riscv_expand_conditional_move_onesided):
Delete.
(riscv_expand_conditional_move):  Reuse the TARGET_SFB_ALU expand
process for TARGET_XTHEADCONDMOV

gcc/testsuite/ChangeLog:

* gcc.target/riscv/xtheadcondmov-indirect-rv32.c: Update the output.
* gcc.target/riscv/xtheadcondmov-indirect-rv64.c: Likewise.
gcc/config/riscv/riscv.cc
gcc/testsuite/gcc.target/riscv/xtheadcondmov-indirect-rv32.c
gcc/testsuite/gcc.target/riscv/xtheadcondmov-indirect-rv64.c