]> git.ipfire.org Git - thirdparty/gcc.git/commit
[PATCH 1/5][V3][ifcvt] optimize x=c ? (y op z) : y by RISC-V Zicond like insns
authorFei Gao <gaofei@eswincomputing.com>
Fri, 8 Dec 2023 00:51:08 +0000 (17:51 -0700)
committerJeff Law <jlaw@ventanamicro.com>
Fri, 8 Dec 2023 00:53:21 +0000 (17:53 -0700)
commit9f7ad5eff3bf1e42aac0825b37d2c9ab43eaafd2
tree126a8613e3b8e2168862cab6bc93778c7aa5d9c4
parent775aeabcb870b74e4d0986341c7a39add9bbb06d
[PATCH 1/5][V3][ifcvt] optimize x=c ? (y op z) : y by RISC-V Zicond like insns

op=[PLUS, MINUS, IOR, XOR]

Conditional op, if zero
rd = (rc == 0) ? (rs1 op rs2) : rs1
-->
czero.nez rd, rs2, rc
op rd, rs1, rd

Conditional op, if non-zero
rd = (rc != 0) ? (rs1 op rs2) : rs1
-->
czero.eqz rd, rs2, rc
op rd, rs1, rd

gcc/ChangeLog:

* ifcvt.cc (noce_try_cond_zero_arith): New function.
(noce_emit_czero, get_base_reg): Likewise.
(noce_cond_zero_binary_op_supported): Likewise.
(noce_bbs_ok_for_cond_zero_arith): Likewise.
(noce_process_if_block): Use noce_try_cond_zero_arith.

Co-authored-by: Xiao Zeng<zengxiao@eswincomputing.com>
gcc/ifcvt.cc
gcc/testsuite/gcc.target/riscv/zicond_ifcvt_opt.c [new file with mode: 0644]