diff options
author | Andrew Pinski <quic_apinski@quicinc.com> | 2024-01-23 17:42:51 +0000 |
---|---|---|
committer | Richard Sandiford <richard.sandiford@arm.com> | 2024-01-23 17:42:51 +0000 |
commit | 06ee648e9bb8c121fbd93659f81d3380dba8be09 (patch) | |
tree | b11f086d76a5dcb8dd149b4afacb2a7747382b81 /gcc/cfgexpand.cc | |
parent | cc082cf97e21dad37c4983572218a22ce0c3036c (diff) | |
download | gcc-06ee648e9bb8c121fbd93659f81d3380dba8be09.zip gcc-06ee648e9bb8c121fbd93659f81d3380dba8be09.tar.gz gcc-06ee648e9bb8c121fbd93659f81d3380dba8be09.tar.bz2 |
aarch64/expr: Use ccmp when the outer expression is used twice [PR100942]
Ccmp is not used if the result of the and/ior is used by both
a GIMPLE_COND and a GIMPLE_ASSIGN. This improves the code generation
here by using ccmp in this case.
Two changes is required, first we need to allow the outer statement's
result be used more than once.
The second change is that during the expansion of the gimple, we need
to try using ccmp. This is needed because we don't use expand the ssa
name of the lhs but rather expand directly from the gimple.
A small note on the ccmp_4.c testcase, we should be able to get slightly
better than with this patch but it is one extra instruction compared to
before.
PR target/100942
gcc/ChangeLog:
* ccmp.cc (ccmp_candidate_p): Add outer argument.
Allow if the outer is true and the lhs is used more
than once.
(expand_ccmp_expr): Update call to ccmp_candidate_p.
* expr.h (expand_expr_real_gassign): Declare.
* expr.cc (expand_expr_real_gassign): New function, split out from...
(expand_expr_real_1): ...here.
* cfgexpand.cc (expand_gimple_stmt_1): Use expand_expr_real_gassign.
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/ccmp_3.c: New test.
* gcc.target/aarch64/ccmp_4.c: New test.
* gcc.target/aarch64/ccmp_5.c: New test.
Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
Co-Authored-By: Richard Sandiford <richard.sandiford@arm.com>
Diffstat (limited to 'gcc/cfgexpand.cc')
-rw-r--r-- | gcc/cfgexpand.cc | 31 |
1 files changed, 6 insertions, 25 deletions
diff --git a/gcc/cfgexpand.cc b/gcc/cfgexpand.cc index 767982a..316b883 100644 --- a/gcc/cfgexpand.cc +++ b/gcc/cfgexpand.cc @@ -3997,37 +3997,18 @@ expand_gimple_stmt_1 (gimple *stmt) { rtx target, temp; bool nontemporal = gimple_assign_nontemporal_move_p (assign_stmt); - struct separate_ops ops; bool promoted = false; target = expand_expr (lhs, NULL_RTX, VOIDmode, EXPAND_WRITE); if (GET_CODE (target) == SUBREG && SUBREG_PROMOTED_VAR_P (target)) promoted = true; - ops.code = gimple_assign_rhs_code (assign_stmt); - ops.type = TREE_TYPE (lhs); - switch (get_gimple_rhs_class (ops.code)) - { - case GIMPLE_TERNARY_RHS: - ops.op2 = gimple_assign_rhs3 (assign_stmt); - /* Fallthru */ - case GIMPLE_BINARY_RHS: - ops.op1 = gimple_assign_rhs2 (assign_stmt); - /* Fallthru */ - case GIMPLE_UNARY_RHS: - ops.op0 = gimple_assign_rhs1 (assign_stmt); - break; - default: - gcc_unreachable (); - } - ops.location = gimple_location (stmt); - - /* If we want to use a nontemporal store, force the value to - register first. If we store into a promoted register, - don't directly expand to target. */ + /* If we want to use a nontemporal store, force the value to + register first. If we store into a promoted register, + don't directly expand to target. */ temp = nontemporal || promoted ? NULL_RTX : target; - temp = expand_expr_real_2 (&ops, temp, GET_MODE (target), - EXPAND_NORMAL); + temp = expand_expr_real_gassign (assign_stmt, temp, + GET_MODE (target), EXPAND_NORMAL); if (temp == target) ; @@ -4039,7 +4020,7 @@ expand_gimple_stmt_1 (gimple *stmt) if (CONSTANT_P (temp) && GET_MODE (temp) == VOIDmode) { temp = convert_modes (GET_MODE (target), - TYPE_MODE (ops.type), + TYPE_MODE (TREE_TYPE (lhs)), temp, unsignedp); temp = convert_modes (GET_MODE (SUBREG_REG (target)), GET_MODE (target), temp, unsignedp); |