Hi, when a call to a function is inlined and takes a parameter whose type is not gimple_reg, a variable is created in the caller to hold a copy of the argument passed in the call with the following comment: /* We may produce non-gimple trees by adding NOPs or introduce invalid sharing when operand is not really constant. It is not big deal to prohibit constant propagation here as we will constant propagate in DOM1 pass anyway. * Of course the second sentence of the comment does not apply to non-gimple_reg values, unless they get SRAed later, because we do not do constant propagation for them. This for example prevents two identical calls to a pure function from being merged in the attached Ada testcase. Therefore the attached patch attempts to reuse a read-only or non-addressable local DECL of the caller, the hitch being that expand_call_inline needs to be prevented from creating a CLOBBER for the cases where it ends uo being reused. Tested on x86-64/Linux, OK for the mainline? 2021-05-03 Eric Botcazou * tree-inline.c (setup_one_parameter): Do not create a variable if the value is either a read-only DECL or a non-addressable local variable. Register the variable thus reused instead of creating a new one. (expand_call_inline): Do not generate a CLOBBER for these variables. 2021-05-03 Eric Botcazou * gnat.dg/opt94.adb: New test. * gnat.dg/opt94_pkg.ads, opt94.adb: New helper. -- Eric Botcazou