> Am 06.07.2025 um 02:22 schrieb Andrew Pinski <quic_apin...@quicinc.com>:
> 
> For GIMPLE_SINGLE_RHS, we don't currently test LHS for some invalid cases.
> In this case all constants and ADDR_EXPR should be invalid on the LHS.
> Also for vector (non-empty) constructors, the LHS needs to be an 
> is_gimple_reg.
> 
> This adds the checks.
> Also this fixes the following gimple testcase so it no longer ICEs, all 
> functions are correctly rejected:
> ```
> typedef vector int vi;
> 
> void __GIMPLE b1(int t) {
>  1 = t;
> }
> void __GIMPLE b2() {
>  1 = 2;
> }
> void __GIMPLE b3(int t, int t1) {
>  &t1 = &t;
> }
> void __GIMPLE b4(vi t, vi t1) {
>  _Literal(vi){0} = _Literal(vi){1};
> }
> void __GIMPLE b5(vi t, vi t1) {
>  _Literal(vi){t} = _Literal(vi){t1};
> }
> ```
> 
> Bootstrapped and tested on x86_64-linux-gnu.

Ok

Thanks,
Richard 

>    PR middle-end/120921
> gcc/ChangeLog:
> 
>    * tree-cfg.cc (verify_gimple_assign_single): Reject constant and address 
> expression LHS.
>    For non-empty vector constructors, make sure the LHS is an is_gimple_reg.
> 
> Signed-off-by: Andrew Pinski <quic_apin...@quicinc.com>
> ---
> gcc/tree-cfg.cc | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
> 
> diff --git a/gcc/tree-cfg.cc b/gcc/tree-cfg.cc
> index 72763fd5a55..9a5479a2d38 100644
> --- a/gcc/tree-cfg.cc
> +++ b/gcc/tree-cfg.cc
> @@ -4623,6 +4623,14 @@ verify_gimple_assign_single (gassign *stmt)
>       return true;
>     }
> 
> +  /* LHS can't be a constant or an address expression. */
> +  if (CONSTANT_CLASS_P (lhs)|| TREE_CODE (lhs) == ADDR_EXPR)
> +    {
> +      error ("invalid LHS (%qs) for assignment: %qs",
> +         get_tree_code_name (TREE_CODE (lhs)), code_name);
> +      return true;
> +    }
> +
>   if (gimple_clobber_p (stmt)
>       && !(DECL_P (lhs) || TREE_CODE (lhs) == MEM_REF))
>     {
> @@ -4745,6 +4753,11 @@ verify_gimple_assign_single (gassign *stmt)
> 
>      if (CONSTRUCTOR_NELTS (rhs1) == 0)
>        return res;
> +      if (!is_gimple_reg (lhs))
> +        {
> +          error ("non-register as LHS with vector constructor");
> +          return true;
> +        }
>      /* For vector CONSTRUCTORs we require that either it is empty
>         CONSTRUCTOR, or it is a CONSTRUCTOR of smaller vector elements
>         (then the element count must be correct to cover the whole
> --
> 2.43.0
> 

Reply via email to