Thanks Jeff. Address Jeff's comment and resend fix patch: https://gcc.gnu.org/pipermail/gcc-patches/2023-April/616170.html This patch also added a testcase coming from Kito (Kito reduced google/highway testcase from over 10W lines codes into 100 lines codes!!!). juzhe.zhong@rivai.ai From: Jeff Law Date: 2023-04-19 13:43 To: juzhe.zhong@rivai.ai; kito.cheng; Richard Biener CC: gcc-patches; palmer Subject: Re: [PATCH] RISC-V: Fix bug reported by PR109535 On 4/18/23 19:29, juzhe.zhong@rivai.ai wrote: > I tried refers_to_regno_p > It can not work for us since it just return true or false whether the > "rtx" has the regno. Use refers_to_regno_p instead of the equality comparison for the REGNO. So you're still going to have count_regno_occurrences, you're just changing the test it uses so that it works for modes which potentially span multiple hard registers. Note that you'll want to pass in AVL rather than REGNO (avl). When you call refers_to_regno_p it'll look something like tmp = REGNO (avl); mode = GET_MODE (avl); if (REG_P (recog_data.operand[i]) && refers_to_regno_p (tmp, hard_regno_nregs (tmp, mode), recog_data.operand[i], NULL)) Or something like that. I'm assuming AVL is a hard register at this point. If it could be a pseudo the code will be slightly different. I'm still not sure all this stuff is handling SUBREGs properly either. Though if it's only checked after reload, we should be OK as we should have simplified the subreg away. Jeff