Hi, As mentioned in PR, note_simd_array_uses (and adjust_simduid_builtins), crash while processing GOMP internal functions (GOMP_SIMD_VF) in SIMT region. This happens because in SIMT region, first argument to GOMP internal function is lhs of call to IFN_GOMP_SIMT_ENTER, rather than default definition, which results in segfault while accessing SSA_NAME_VAR (gimple_call_arg (stmt, 0)), where arg is simduid.
The attached patch simply skips processing of simduid if it's not default def (which'd indicate it's in SIMT region), which seems to fix the issue. I am assuming that'd be OK (instead of walking SSA use-def chain to obtain default def and corresponding simduid var) since SIMT region would be dead-code on host side ? On nvptx side, the builtins get folded in ompdevlow pass itself. Patch passes libgomp testing on AArch64/nvptx offloading, and bootstrap+test on aarch64-linux-gnu. Does it look OK ? Signed-off-by: Prathamesh Kulkarni <prathame...@nvidia.com> Thanks, Prathamesh
Skip processing simduid if it's in SIMT region. gcc/ChangeLog: * tree-vectorizer.cc (note_simd_array_uses): Skip processing of simduid arg if it's not default def. (adjust_simduid_builtins): Check if simduid arg is default def before looking up corresponding vf. Signed-off-by: Prathamesh Kulkarni <prathame...@nvidia.com> diff --git a/gcc/tree-vectorizer.cc b/gcc/tree-vectorizer.cc index 92ecd881508..e83bb903f0d 100644 --- a/gcc/tree-vectorizer.cc +++ b/gcc/tree-vectorizer.cc @@ -307,16 +307,20 @@ adjust_simduid_builtins (hash_table<simduid_to_vf> *htab, function *fun) gcc_assert (arg != NULL_TREE); gcc_assert (TREE_CODE (arg) == SSA_NAME); simduid_to_vf *p = NULL, data; - data.simduid = DECL_UID (SSA_NAME_VAR (arg)); - /* Need to nullify loop safelen field since it's value is not - valid after transformation. */ - if (bb->loop_father && bb->loop_father->safelen > 0) - bb->loop_father->safelen = 0; - if (htab) + /* Skip processing simduid var if it occurs in SIMT region. */ + if (SSA_NAME_IS_DEFAULT_DEF (arg)) { - p = htab->find (&data); - if (p) - vf = p->vf; + data.simduid = DECL_UID (SSA_NAME_VAR (arg)); + /* Need to nullify loop safelen field since it's value is not + valid after transformation. */ + if (bb->loop_father && bb->loop_father->safelen > 0) + bb->loop_father->safelen = 0; + if (htab) + { + p = htab->find (&data); + if (p) + vf = p->vf; + } } switch (ifn) { @@ -418,6 +422,11 @@ note_simd_array_uses (hash_table<simd_array_to_simduid> **htab, function *fun) continue; imm_use_iterator use_iter; gimple *use_stmt; + tree simduid_arg = gimple_call_arg (stmt, 0); + /* A non-default ssa def for simduid_arg indicates that it's + in SIMT region, so skip it. */ + if (!SSA_NAME_IS_DEFAULT_DEF (simduid_arg)) + continue; ns.simduid = DECL_UID (SSA_NAME_VAR (gimple_call_arg (stmt, 0))); FOR_EACH_IMM_USE_STMT (use_stmt, use_iter, lhs) if (!is_gimple_debug (use_stmt))