[Mesa-dev] [PATCH 09/17] spirv: Silence compiler warning about undefined srcs[0]

Eric Engestrom eric.engestrom at imgtec.com
Tue Feb 13 14:50:28 UTC 2018


On Monday, 2018-02-12 13:52:23 -0800, Ian Romanick wrote:
> On 02/10/2018 08:33 AM, Eric Anholt wrote:
> > It doesn't know that elems >= 1.
> 
> Does adding assume(elems >= 1) help?

Indeed, I was going to reply this too; I think a number of "let's
always initialise to shut the compiler up" patches in this series
should actually be "let's tell the compiler this isn't possible
because `elems > 0`"

> 
> > Cc: Jason Ekstrand <jason.ekstrand at intel.com>
> > ---
> >  src/compiler/spirv/spirv_to_nir.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c
> > index c6df764682ec..f86d45511df8 100644
> > --- a/src/compiler/spirv/spirv_to_nir.c
> > +++ b/src/compiler/spirv/spirv_to_nir.c
> > @@ -2923,7 +2923,7 @@ vtn_handle_composite(struct vtn_builder *b, SpvOp opcode,
> >     case SpvOpCompositeConstruct: {
> >        unsigned elems = count - 3;
> >        if (glsl_type_is_vector_or_scalar(type)) {
> > -         nir_ssa_def *srcs[4];
> > +         nir_ssa_def *srcs[4] = { NULL };
> >           for (unsigned i = 0; i < elems; i++)
> >              srcs[i] = vtn_ssa_value(b, w[3 + i])->def;
> >           val->ssa->def =
> > 
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list