On 12/6/2021 11:43 AM, Robin Dapp via Gcc-patches wrote:
Following up on the previous patch, this patch makes
noce_convert_multiple emit two cmov sequences: The same one as before
and a second one that tries to re-use the existing CC. Then their costs
are compared and the cheaper one is selected.
---
gcc/ifcvt.c | 112 +++++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 88 insertions(+), 24 deletions(-)
diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c
index 3e78e1bb03d..d1e7db1ee27 100644
--- a/gcc/ifcvt.c
+++ b/gcc/ifcvt.c
@@ -83,7 +83,7 @@ static rtx_insn *last_active_insn (basic_block, int);
static rtx_insn *find_active_insn_before (basic_block, rtx_insn *);
static rtx_insn *find_active_insn_after (basic_block, rtx_insn *);
static basic_block block_fallthru (basic_block);
-static rtx cond_exec_get_condition (rtx_insn *);
+static rtx cond_exec_get_condition (rtx_insn *, bool);
static rtx noce_get_condition (rtx_insn *, rtx_insn **, bool);
static int noce_operand_ok (const_rtx);
static void merge_if_block (ce_if_block *);
@@ -427,7 +427,7 @@ cond_exec_process_insns (ce_if_block *ce_info
ATTRIBUTE_UNUSED,
/* Return the condition for a jump. Do not do any special processing. */
static rtx
-cond_exec_get_condition (rtx_insn *jump)
+cond_exec_get_condition (rtx_insn *jump, bool get_reversed = false)
{
rtx test_if, cond;
@@ -439,8 +439,9 @@ cond_exec_get_condition (rtx_insn *jump)
/* If this branches to JUMP_LABEL when the condition is false,
reverse the condition. */
- if (GET_CODE (XEXP (test_if, 2)) == LABEL_REF
- && label_ref_label (XEXP (test_if, 2)) == JUMP_LABEL (jump))
+ if (get_reversed || (GET_CODE (XEXP (test_if, 2)) == LABEL_REF
+ && label_ref_label (XEXP (test_if, 2))
+ == JUMP_LABEL (jump)))
Just a formatting nit. Bring the condition after get_reversed down to
a new line and reindent appropriately. ie
if (get_reversed
|| (blah blah blah
&& more blah == frobit))
{
enum rtx_code rev = reversed_comparison_code (cond, jump);
if (rev == UNKNOWN)
@@ -3146,6 +3147,46 @@ bb_valid_for_noce_process_p (basic_block test_bb, rtx
cond,
return false;
}
+/* Helper function to emit a cmov sequence. */
+
+static rtx_insn*
+try_emit_cmove_seq (struct noce_if_info *if_info, rtx temp,
+ rtx cond, rtx new_val, rtx old_val, bool need_cmov,
+ unsigned *cost, rtx *temp_dest,
+ rtx cc_cmp = NULL, rtx rev_cc_cmp = NULL)
Could you expand the function comment a bit here. Saying something is a
helper doesn't really help the reader understand what the purpose of the
function really is.
With the formatting nit fixed, a better function comment and a suitable
ChangeLog, this is fine.
jeff