On Fri, 28 Jan 2022, Richard Biener wrote:

> > that's not what it does.  It treats it like
> >
> >   float tem = f;
> >   return x + { tem, tem, tem, tem };
> >
> > avoiding, like for x + (1.0f + f) creating
> >
> >   return x + { 1.0+f, 1.0+f, 1.0+f ...}
> >
> > it's more CSE than volatile qualifying.

 I see, thanks for your time to explain me.  I got this confused.

> > Because the IL from the frontends should not depend on target capabilities
> > and whether we have to preserve side-effects properly doesn't depend on
> > the cheapness of the operation itself.  Consider
> >
> >   return x + bar (f);
> >
> > you definitely want bar(f) to be only evaluated once, even when the
> > target can cheaply do the splat.

 Indeed.

> Btw,
> 
> diff --git a/gcc/tree-cfg.cc b/gcc/tree-cfg.cc
> index efd10332c53..c0f7d98931d 100644
> --- a/gcc/tree-cfg.cc
> +++ b/gcc/tree-cfg.cc
> @@ -4703,6 +4703,12 @@ verify_gimple_assign_single (gassign *stmt)
>           debug_generic_stmt (rhs1);
>           return true;
>         }
> +      if (TREE_SIDE_EFFECTS (rhs1) && !gimple_clobber_p (stmt))
> +       {
> +         error ("%qs with side-effects", code_name);
> +         debug_generic_stmt (rhs1);
> +         return true;
> +       }
>        return res;
> 
>      case ASSERT_EXPR:
> 
> does not cause ICEs on the two testcases (on trunk).

 Right, so it has turned out I had the wrong binary run under GDB, sigh.  
I have re-verified the current trunk and indeed the side-effect annotation 
has gone:

(gdb) frame
#0  store_constructor (exp=<constructor 0x7ffff5b36e88>,
    target=0x7ffff5b388e0, cleared=0, size=..., reverse=false)
    at .../gcc/expr.cc:7169
7169            if (!TREE_SIDE_EFFECTS (exp)
(gdb) pt exp
 <constructor 0x7ffff5b36e88
    type <vector_type 0x7ffff5e23678 v4sf
        type <real_type 0x7ffff5c41260 float sizes-gimplified SF
            size <integer_cst 0x7ffff5b31050 constant 32>
            unit-size <integer_cst 0x7ffff5b31068 constant 4>
            align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 
0x7ffff5c41260 precision:32
            pointer_to_this <pointer_type 0x7ffff5c41848>>
        sizes-gimplified V4SF
        size <integer_cst 0x7ffff5b30e58 constant 128>
        unit-size <integer_cst 0x7ffff5b30e70 constant 16>
        align:128 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 
0x7ffff5c6d740 nunits:4 context <translation_unit_decl 0x7ffff5e908e8 v4sf.c>>
    length:4
    val <ssa_name 0x7ffff5bd1200 type <real_type 0x7ffff5c41260 float>
        visited var <parm_decl 0x7ffff7f80100 y>
        def_stmt GIMPLE_NOP
        version:2>
    val <ssa_name 0x7ffff5bd1200 type <real_type 0x7ffff5c41260 float>
        visited var <parm_decl 0x7ffff7f80100 y>
        def_stmt GIMPLE_NOP
        version:2>
    val <ssa_name 0x7ffff5bd1200 type <real_type 0x7ffff5c41260 float>
        visited var <parm_decl 0x7ffff7f80100 y>
        def_stmt GIMPLE_NOP
        version:2>
    val <ssa_name 0x7ffff5bd1200 type <real_type 0x7ffff5c41260 float>
        visited var <parm_decl 0x7ffff7f80100 y>
        def_stmt GIMPLE_NOP
        version:2>>
(gdb)

and I have tracked down commit 512429a885e8 ("tree-optimization/99863 - 
clear vector CTOR TREE_SIDE_EFFECTS") of yours to be the change required.

 Thank you for your assistance!

  Maciej

Reply via email to