On 11/8/26 9:12 AM, Souradipto Das wrote:
This patch removes the copy insn from the form
(insn 9 8 11 3 (set (reg:DI 137)
(sign_extend:DI (plus:SI (subreg/s/u:SI (reg/v:DI 135 [ x ]) 0)
(const_int 1 [0x1])))) "test.c":3:24 discrim 1 6
{addsi3_extended}
(expr_list:REG_DEAD (reg/v:DI 135 [ x ])
(nil)))
(insn 11 9 24 3 (set (reg:DI 134 [ <retval> ])
(reg:DI 137)) "test.c":3:24 discrim 1 275 {*movdi_64bit}
(nil))
by deleting the copy which is insn 11 in this case and substituting the return
value
register into insn 9 and thereby making the block simple for
noce_try_cond_arith to
succeed and produce the optimal code as in :
test_05_3:
sgt a5,a0,zero
addw a0,a5,a0
ret
The patch also additionally checks if the src of the else set is a simple
register
without which it produces branched instructions for cases where the src is a
sign
extend.
This patch was bootstrapped and regtested in local x86_64-pc-linux-gnu with no
new
fails and cross compile tested on qemu as riscv64-linux-gnu with no new fails.
Is this patch safe for trunk?
gcc/ChangeLog:
PR rtl-optimization/122335
* ifcvt.cc (*noce_process_if_block) : Added checks to safely delete the
copy insn.
gcc/testsuite/ChangeLog:
PR rtl-optimization/122335
* gcc.target/riscv/pr122335.c : New Test.
Signed-off-by: Souradipto Das <[email protected]>
Sashiko flagged several concerns. I haven't not looked at them in
detail, but if you could and either spin a V2 with the real issues fixed
or note why the Sashiko issues were false positives, it'd be appreciated.
https://gcc.sashiko.dev/#/patchset/20261108161230.227969-1-souradiptodas6%40gmail.com
You also need to either put your contribution under the terms of the DCO
or get a copyright assignment on file. This is large enough to trigger
copyright interest.
Jeff