It looks fine to me. Please go ahead and check it in.

2010/9/8 Xiaohua Zhang <xiaohua_zh...@yahoo.com>

> Hi,
>
> Could a gatekeeper please review the fix for bug 592?
> It happens when the initializer list for vector typed variable is empty.
> The code used to get the element type from initializer, when it is empty,
> the code gets a null pointer access. Now it is changed to use the vector
> MTYPE to get its element type.
>
> __attribute__ ((vector_size (sizeof (double) * 4))) double d1 = { 1., 2 };
> __attribute__ ((vector_size (sizeof (double) * 4))) double d2 = { };
> __attribute__ ((vector_size (sizeof (float) * 4))) float f1 = { 1., 2 };
> __attribute__ ((vector_size (sizeof (float) * 4))) float f2 = { };
> __attribute__ ((vector_size (sizeof (int) * 4))) int a = { 1, 2 };
> __attribute__ ((vector_size (sizeof (int) * 4))) int c = { };
>
> Thanks,
> -Xiaohua
>
> Index: common/com/mtypes.cxx
> ===================================================================
> --- common/com/mtypes.cxx       (revision 3336)
> +++ common/com/mtypes.cxx       (working copy)
> @@ -482,7 +482,6 @@
>    return Machine_Prev_Alignment[type];
>  }
> -#if defined(TARG_X8664)
>  /* ====================================================================
>   *
>   * TYPE_ID Mtype_vector_elemtype(TYPE_ID)
> @@ -494,6 +493,7 @@
>  TYPE_ID  Mtype_vector_elemtype(TYPE_ID type)
>  {
>    switch (type) {
> +#if defined(TARG_X8664)
>      case MTYPE_V32F8:
>      case MTYPE_V16F8:
>        return MTYPE_F8;
> @@ -526,9 +526,9 @@
>      case MTYPE_V8I1:
>      case MTYPE_M8I1:
>        return MTYPE_I1;
> +#endif
>      default:
>        return type;
>    }
>  }
> -#endif
> Index: common/com/mtypes.h
> ===================================================================
> --- common/com/mtypes.h (revision 3336)
> +++ common/com/mtypes.h (working copy)
> @@ -317,9 +317,7 @@
>  extern TYPE_ID  Mtype_next_alignment( TYPE_ID);
>  extern TYPE_ID  Mtype_prev_alignment( TYPE_ID);
> -#if defined (TARG_X8664)
>  extern TYPE_ID  Mtype_vector_elemtype( TYPE_ID);
> -#endif
>  #ifdef __cplusplus
>  }
> Index: wgen/wgen_decl.cxx
> ===================================================================
> --- wgen/wgen_decl.cxx  (revision 3336)
> +++ wgen/wgen_decl.cxx  (working copy)
> @@ -2351,13 +2351,14 @@
>    init = gs_tree_vector_cst_elts (init_list);
> -  gs_t size = gs_type_size (gs_tree_type (gs_tree_value (init)));
> -  Is_True (gs_tree_code (size) == GS_INTEGER_CST,
> -           ("WGEN_Add_Aggregate_Init_Vector: Vector of variable-sized
> units?"));
> -
> -  UINT esize = gs_get_integer_value(size) / BITSPERBYTE;
> +  // find the element size from vector mtype
> +  TY_IDX vector_type = Get_TY(gs_tree_type(init_list));
> +  Is_True (MTYPE_is_vector(TY_mtype(vector_type)),
> +            ("WGEN_Add_Aggregate_Init_Vector: invalid vector type"));
> +  TYPE_ID elem_mtype = Mtype_vector_elemtype(TY_mtype(vector_type));
> +  UINT esize = MTYPE_byte_size(elem_mtype);
>    UINT nunits = vec_size / esize;
> -  gs_code_t code = gs_tree_code (gs_tree_value (init));
> +  gs_code_t code = MTYPE_is_integral(elem_mtype) ? GS_INTEGER_CST :
> GS_REAL_CST;
>    for (i = 0;
>         init;
>
>
>
> ------------------------------------------------------------------------------
> This SF.net Dev2Dev email is sponsored by:
>
> Show off your parallel programming skills.
> Enter the Intel(R) Threading Challenge 2010.
> http://p.sf.net/sfu/intel-thread-sfd
> _______________________________________________
> Open64-devel mailing list
> Open64-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/open64-devel
>
>


-- 
Regards,
Lai Jian-Xin
------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
Open64-devel mailing list
Open64-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/open64-devel

Reply via email to