2020-05-14 Jakub Jelinek <jakub@redhat.com>
+ PR middle-end/95108
+ * omp-simd-clone.c (struct modify_stmt_info): Add after_stmt member.
+ (ipa_simd_modify_stmt_ops): For PHIs, only add before first stmt in
+ entry block if info->after_stmt is NULL, otherwise add after that stmt
+ and update it after adding each stmt.
+ (ipa_simd_modify_function_body): Initialize info.after_stmt.
+
* function.h (struct function): Add has_omp_target bit.
* omp-offload.c (omp_discover_declare_target_fn_r): New function,
old renamed to ...
struct modify_stmt_info {
ipa_param_body_adjustments *adjustments;
gimple *stmt;
+ gimple *after_stmt;
/* True if the parent statement was modified by
ipa_simd_modify_stmt_ops. */
bool modified;
gimple_stmt_iterator gsi;
if (gimple_code (info->stmt) == GIMPLE_PHI)
{
- gsi = gsi_after_labels (single_succ (ENTRY_BLOCK_PTR_FOR_FN (cfun)));
+ if (info->after_stmt)
+ gsi = gsi_for_stmt (info->after_stmt);
+ else
+ gsi = gsi_after_labels (single_succ (ENTRY_BLOCK_PTR_FOR_FN (cfun)));
/* Cache SSA_NAME for next time. */
if (pbr
&& TREE_CODE (*orig_tp) == ADDR_EXPR
}
else
gsi = gsi_for_stmt (info->stmt);
- gsi_insert_before (&gsi, stmt, GSI_SAME_STMT);
+ if (info->after_stmt)
+ gsi_insert_after (&gsi, stmt, GSI_SAME_STMT);
+ else
+ gsi_insert_before (&gsi, stmt, GSI_SAME_STMT);
+ if (gimple_code (info->stmt) == GIMPLE_PHI)
+ info->after_stmt = stmt;
*orig_tp = repl;
}
else if (!useless_type_conversion_p (TREE_TYPE (*tp), TREE_TYPE (repl)))
gphi *phi = as_a <gphi *> (gsi_stmt (gsi));
int i, n = gimple_phi_num_args (phi);
info.stmt = phi;
+ info.after_stmt = NULL;
struct walk_stmt_info wi;
memset (&wi, 0, sizeof (wi));
info.modified = false;
{
gimple *stmt = gsi_stmt (gsi);
info.stmt = stmt;
+ info.after_stmt = NULL;
struct walk_stmt_info wi;
memset (&wi, 0, sizeof (wi));