[PATCH] LRA: side_effects_p stmts' output is not invariant (PR89721)

Vladimir Makarov vmakarov@redhat.com
Fri Mar 15 20:31:00 GMT 2019


On 2019-03-15 2:30 p.m., Segher Boessenkool wrote:
> PR89721 shows LRA treating an unspec_volatile's result as invariant,
> which of course isn't correct.  This patch fixes it.
Segher, thank you for fixing this.  The patch is ok to commit.
> Question.  Is side_effects_p the correct check?  Or do we want to
> allow PRE_INC etc. here?  What about CALL?
>
No, we don't want INC/DEC.  Inheritance helps to reuse some reloaded 
values which are expensive for calculation.  So if we have two INCs, we 
will have only one, which is wrong.  The same is for calls.

   I believe we can ignore calls here because LRA does not reload calls 
(call result reg).  Actually I believe the same is true for INC/DEC (we 
can reload INC/DEC regs but not INC/DEC themselves).


> Segher
>
>
> 2019-04-15  Segher Boessenkool  <segher@kernel.crashing.org>
>
> 	PR rtl-optimization/89721
> 	* lra-constraints (invariant_p): Return false if side_effects_p holds.
>
> ---
>   gcc/lra-constraints.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c
> index afbd5d0..24f11ed 100644
> --- a/gcc/lra-constraints.c
> +++ b/gcc/lra-constraints.c
> @@ -5839,6 +5839,9 @@ invariant_p (const_rtx x)
>     enum rtx_code code;
>     int i, j;
>   
> +  if (side_effects_p (x))
> +    return false;
> +
>     code = GET_CODE (x);
>     mode = GET_MODE (x);
>     if (code == SUBREG)



More information about the Gcc-patches mailing list