aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2021-03-26 16:08:36 +0000
committerRichard Sandiford <richard.sandiford@arm.com>2021-03-26 16:08:36 +0000
commit99f94ae5018e915d0c1db1b6d4110d68bc4d242e (patch)
tree31a7f223f3c1ae9721ab60e97b6353070631b75a /gcc
parented17ad5ea1cb302951f582ae8edd1afc9c014302 (diff)
downloadgcc-99f94ae5018e915d0c1db1b6d4110d68bc4d242e.zip
gcc-99f94ae5018e915d0c1db1b6d4110d68bc4d242e.tar.gz
gcc-99f94ae5018e915d0c1db1b6d4110d68bc4d242e.tar.bz2
aarch64: Cost comparisons embedded in COND_EXPRs
So far the costing of COND_EXPRs hasn't distinguished between cases in which the condition is calculated separately or is built into the COND_EXPR itself. This patch adds the cost of any embedded comparison. Like with the previous patches, this one only becomes active if a CPU selects use_new_vector_costs. It should therefore have a very low impact on other CPUs. gcc/ * config/aarch64/aarch64.c (aarch64_embedded_comparison_type): New function. (aarch64_adjust_stmt_cost): Add the costs of embedded scalar and vector comparisons.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/config/aarch64/aarch64.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index e2d92f0..e97e71b 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -14392,6 +14392,21 @@ aarch64_ld234_st234_vectors (vect_cost_for_stmt kind, stmt_vec_info stmt_info)
return 0;
}
+/* If STMT_INFO is a COND_EXPR that includes an embedded comparison, return the
+ scalar type of the values being compared. Return null otherwise. */
+static tree
+aarch64_embedded_comparison_type (stmt_vec_info stmt_info)
+{
+ if (auto *assign = dyn_cast<gassign *> (stmt_info->stmt))
+ if (gimple_assign_rhs_code (assign) == COND_EXPR)
+ {
+ tree cond = gimple_assign_rhs1 (assign);
+ if (COMPARISON_CLASS_P (cond))
+ return TREE_TYPE (TREE_OPERAND (cond, 0));
+ }
+ return NULL_TREE;
+}
+
/* Return true if creating multiple copies of STMT_INFO for Advanced SIMD
vectors would produce a series of LDP or STP operations. KIND is the
kind of statement that STMT_INFO represents. */
@@ -14685,8 +14700,26 @@ aarch64_adjust_stmt_cost (vect_cost_for_stmt kind, stmt_vec_info stmt_info,
stmt_cost += simd_costs->ld4_st4_permute_cost;
break;
}
+
+ if (kind == vector_stmt || kind == vec_to_scalar)
+ if (tree cmp_type = aarch64_embedded_comparison_type (stmt_info))
+ {
+ if (FLOAT_TYPE_P (cmp_type))
+ stmt_cost += simd_costs->fp_stmt_cost;
+ else
+ stmt_cost += simd_costs->int_stmt_cost;
+ }
}
+ if (kind == scalar_stmt)
+ if (tree cmp_type = aarch64_embedded_comparison_type (stmt_info))
+ {
+ if (FLOAT_TYPE_P (cmp_type))
+ stmt_cost += aarch64_tune_params.vec_costs->scalar_fp_stmt_cost;
+ else
+ stmt_cost += aarch64_tune_params.vec_costs->scalar_int_stmt_cost;
+ }
+
return stmt_cost;
}