https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119174
--- Comment #10 from Andrew Pinski <pinskia at gcc dot gnu.org> --- So I think the wrong code is due to reload NOT being able to handle: (mem/f:HI (post_inc:HI (reg:HI 26 [ ivtmp.10 ])) [1 MEM[(int (*<T2da>) (int) *)_18]+0 S2 A16]) That is if you look at: ``` void f3(int x, int (*p3 []) (int)) { int i; int next = x; for (i = 0; i < x; i++) next = p3[0](next); } ``` IRA produces: ``` Popping a3(r30,l0) -- assign reg 13 ``` For: ``` (call_insn 14 13 28 3 (set (reg:HI 12 R12) (call:HI (mem:HI (mem/f:HI (reg/f:HI 30 [ p3 ]) [1 *p3_7(D)+0 S2 A16]) [0 *_1 S2 A16]) (const_int 0 [0]))) "t.c":7:12 89 {call_value_internal} (expr_list:REG_CALL_DECL (nil) (nil)) (expr_list:HI (use (reg:HI 12 R12)) (nil))) ``` Which reload is able to handle: ``` .L2: CMP.W 2(R1), R10 { JL .L3 ; start of epilogue ADD.W #4, R1 POPM.W #1, r10 RET .L3: MOV.W R13, @R1 ;;;<<< store MOV.W @R13, R14 CALL R14 ADD.W #1, R10 MOV.W @R1, R13 ;; << load BR #.L2 ``` BUT then again this is less than optimal here. because we are doing the save/restore of r13 around the function call.