diff options
author | Prathamesh Kulkarni <prathameshk@nvidia.com> | 2024-10-08 12:38:31 +0530 |
---|---|---|
committer | Prathamesh Kulkarni <prathameshk@nvidia.com> | 2024-10-08 13:23:19 +0530 |
commit | ae88da5e070659d37b3c3daa4b880531769183bf (patch) | |
tree | 84d266dc53badd4fa5dc649aada95d374ce78d72 | |
parent | d022f6925702b0890a73613d659350b40f44f215 (diff) | |
download | gcc-ae88da5e070659d37b3c3daa4b880531769183bf.zip gcc-ae88da5e070659d37b3c3daa4b880531769183bf.tar.gz gcc-ae88da5e070659d37b3c3daa4b880531769183bf.tar.bz2 |
Recompute TYPE_MODE and DECL_MODE for vector_type for accelerator.
gcc/ChangeLog:
PR ipa/96265
* lto-streamer-in.cc (lto_read_tree_1): Set TYPE_MODE and DECL_MODE
for vector_type if offloading is enabled.
(lto_input_mode_table): Remove handling of vector modes.
* tree-streamer-out.cc (pack_ts_decl_common_value_fields): Stream out
VOIDmode for vector_type if offloading is enabled.
(pack_ts_decl_common_value_fields): Likewise.
Signed-off-by: Prathamesh Kulkarni <prathameshk@nvidia.com>
-rw-r--r-- | gcc/lto-streamer-in.cc | 38 | ||||
-rw-r--r-- | gcc/tree-streamer-out.cc | 6 |
2 files changed, 28 insertions, 16 deletions
diff --git a/gcc/lto-streamer-in.cc b/gcc/lto-streamer-in.cc index 9d0ec5d..15181c3 100644 --- a/gcc/lto-streamer-in.cc +++ b/gcc/lto-streamer-in.cc @@ -1753,16 +1753,30 @@ lto_read_tree_1 (class lto_input_block *ib, class data_in *data_in, tree expr) with -g1, see for example PR113488. */ else if (DECL_P (expr) && DECL_ABSTRACT_ORIGIN (expr) == expr) DECL_ABSTRACT_ORIGIN (expr) = NULL_TREE; + } #ifdef ACCEL_COMPILER - if ((VAR_P (expr) - || TREE_CODE (expr) == PARM_DECL - || TREE_CODE (expr) == FIELD_DECL) - && AGGREGATE_TYPE_P (TREE_TYPE (expr)) - && DECL_MODE (expr) == VOIDmode) - SET_DECL_MODE (expr, TYPE_MODE (TREE_TYPE (expr))); -#endif + if ((VAR_P (expr) + || TREE_CODE (expr) == PARM_DECL + || TREE_CODE (expr) == FIELD_DECL) + && DECL_MODE (expr) == VOIDmode) + { + tree type = TREE_TYPE (expr); + if (AGGREGATE_TYPE_P (type)) + SET_DECL_MODE (expr, TYPE_MODE (type)); + else if (VECTOR_TYPE_P (type)) + SET_DECL_MODE (expr, TYPE_MODE_RAW (type)); } + + if (VECTOR_TYPE_P (expr) && TYPE_MODE (expr) == VOIDmode) + { + poly_uint64 nunits = TYPE_VECTOR_SUBPARTS (expr); + tree innertype = TREE_TYPE (expr); + machine_mode vmode + = mode_for_vector (SCALAR_TYPE_MODE (innertype), nunits).else_blk (); + SET_TYPE_MODE (expr, vmode); + } +#endif } /* Read the physical representation of a tree node with tag TAG from @@ -2106,13 +2120,9 @@ lto_input_mode_table (struct lto_file_decl_data *file_data) case MODE_VECTOR_UFRACT: case MODE_VECTOR_ACCUM: case MODE_VECTOR_UACCUM: - /* For unsupported vector modes just use BLKmode, - if the scalar mode is supported. */ - if (table[(int) inner] != VOIDmode) - { - table[m] = BLKmode; - break; - } + /* Vector modes are recomputed on accel side and shouldn't have + been streamed-out from host. */ + gcc_unreachable (); /* FALLTHRU */ default: /* This is only used for offloading-target compilations and diff --git a/gcc/tree-streamer-out.cc b/gcc/tree-streamer-out.cc index 7de4447..81f5aeb 100644 --- a/gcc/tree-streamer-out.cc +++ b/gcc/tree-streamer-out.cc @@ -194,7 +194,8 @@ pack_ts_decl_common_value_fields (struct bitpack_d *bp, tree expr) && (VAR_P (expr) || TREE_CODE (expr) == PARM_DECL || TREE_CODE (expr) == FIELD_DECL) - && AGGREGATE_TYPE_P (TREE_TYPE (expr))) + && (AGGREGATE_TYPE_P (TREE_TYPE (expr)) + || VECTOR_TYPE_P (TREE_TYPE (expr)))) bp_pack_machine_mode (bp, VOIDmode); else bp_pack_machine_mode (bp, DECL_MODE (expr)); @@ -332,7 +333,8 @@ pack_ts_type_common_value_fields (struct bitpack_d *bp, tree expr) whose size is 256-bits, which is not representable on accelerator. Instead stream out VOIDmode, and while streaming-in, recompute appropriate TYPE_MODE for accelerator. */ - if (lto_stream_offload_p && AGGREGATE_TYPE_P (expr)) + if (lto_stream_offload_p + && (AGGREGATE_TYPE_P (expr) || VECTOR_TYPE_P (expr))) bp_pack_machine_mode (bp, VOIDmode); /* for VECTOR_TYPE, TYPE_MODE reevaluates the mode using target_flags not necessary valid in a global context. |