On Mon, Sep 7, 2026 at 7:51 AM <[email protected]> wrote:
>
> From: Kyrylo Tkachov <[email protected]>
>
> Several C-style idioms that the file no longer needs:

None of these is C style idioms as far as I can tell. Rather most of
this is just a style fix and one removal of ATTRIBUTE_UNUSED (see
below on why removal is ok).

>
> noce_can_force_operand returns an enum insn_code where its declared type is
> bool, relying on CODE_FOR_nothing being zero.  Compare against it instead.
>
> bbs_ok_for_cmove_arith wraps four single-statement failure exits in braces,
> left over from the BITMAP_FREE calls that used to sit next to them.
>
> noce_find_if_block declares if_info and then memsets it seventy lines later.
> Value-initialize it at the declaration.  No functional change.
>
> gcc/ChangeLog:
>
>         * ifcvt.cc (noce_can_force_operand): Return a bool rather than an
>         insn_code.
>         (bbs_ok_for_cmove_arith): Drop braces around single statements.
>         (noce_find_if_block): Value-initialize if_info instead of memsetting 
> it.
>
> Signed-off-by: Kyrylo Tkachov <[email protected]>
> ---
>  gcc/ifcvt.cc | 31 ++++++++++---------------------
>  1 file changed, 10 insertions(+), 21 deletions(-)
>
> diff --git a/gcc/ifcvt.cc b/gcc/ifcvt.cc
> index ca0a0861f77..380cf68ac35 100644
> --- a/gcc/ifcvt.cc
> +++ b/gcc/ifcvt.cc
> @@ -1057,7 +1057,7 @@ noce_can_force_operand (rtx x)
>           auto optab = code_to_optab (GET_CODE (x));
>           if (!optab)
>             return false;
> -         return optab_handler (optab, GET_MODE (x));
> +         return optab_handler (optab, GET_MODE (x)) != CODE_FOR_nothing;
>         }
>      }
>    if (UNARY_P (x))
> @@ -1080,7 +1080,7 @@ noce_can_force_operand (rtx x)
>           auto optab = code_to_optab (GET_CODE (x));
>           if (!optab)
>             return false;
> -         return optab_handler (optab, GET_MODE (x));
> +         return optab_handler (optab, GET_MODE (x)) != CODE_FOR_nothing;
>         }
>      }
>    return false;
> @@ -2294,8 +2294,8 @@ noce_emit_cmove (struct noce_if_info *if_info, rtx x, 
> enum rtx_code code,
>                  rtx cmp_a, rtx cmp_b, rtx vfalse, rtx vtrue, rtx cc_cmp,
>                  rtx rev_cc_cmp)
>  {
> -  rtx target ATTRIBUTE_UNUSED;
> -  bool unsignedp ATTRIBUTE_UNUSED;
> +  rtx target;
> +  bool unsignedp;

Just an FYI, r6-978-g759df569f189ce allowed the removal of
ATTRIBUTE_UNUSED here.  You also don't mention this change (to
noce_emit_cmove) in your changelog nor the commit message ...

This full patch is ok by itself too.

>
>    /* If earliest == jump, try to build the cmove insn directly.
>       This is helpful when combine has created some complex condition
> @@ -2563,9 +2563,7 @@ bbs_ok_for_cmove_arith (basic_block bb_a, basic_block 
> bb_b, rtx to_rename)
>        rtx sset_a = single_set (a_insn);
>
>        if (!sset_a)
> -       {
> -         return false;
> -       }
> +       return false;
>        /* Record all registers that BB_A sets.  */
>        FOR_EACH_INSN_DEF (def, a_insn)
>         if (!(to_rename && DF_REF_REG (def) == to_rename))
> @@ -2582,9 +2580,7 @@ bbs_ok_for_cmove_arith (basic_block bb_a, basic_block 
> bb_b, rtx to_rename)
>        rtx sset_b = single_set (b_insn);
>
>        if (!sset_b)
> -       {
> -         return false;
> -       }
> +       return false;
>
>        /* Make sure this is a REG and not some instance
>          of ZERO_EXTRACT or non-paradoxical SUBREG or other dangerous stuff.
> @@ -2597,18 +2593,12 @@ bbs_ok_for_cmove_arith (basic_block bb_a, basic_block 
> bb_b, rtx to_rename)
>         gcc_assert (rtx_equal_p (SET_DEST (sset_b), to_rename));
>        else if (!REG_P (SET_DEST (sset_b))
>                && !paradoxical_subreg_p (SET_DEST (sset_b)))
> -       {
> -         return false;
> -       }
> +       return false;
>
>        /* If the insn uses a reg set in BB_A return false.  */
>        FOR_EACH_INSN_USE (use, b_insn)
> -       {
> -         if (bitmap_bit_p (bba_sets, DF_REF_REGNO (use)))
> -           {
> -             return false;
> -           }
> -       }
> +       if (bitmap_bit_p (bba_sets, DF_REF_REGNO (use)))
> +         return false;
>
>      }
>
> @@ -5474,7 +5464,7 @@ noce_find_if_block (basic_block test_bb, edge 
> then_edge, edge else_edge,
>    bool then_else_reversed = false;
>    rtx_insn *jump;
>    rtx_insn *cond_earliest;
> -  struct noce_if_info if_info;
> +  noce_if_info if_info = {};
>    bool speed_p = optimize_bb_for_speed_p (test_bb);
>
>    /* We only ever should get here before reload.  */
> @@ -5549,7 +5539,6 @@ noce_find_if_block (basic_block test_bb, edge 
> then_edge, edge else_edge,
>      return false;
>
>    /* Initialize an IF_INFO struct to pass around.  */
> -  memset (&if_info, 0, sizeof if_info);
>    if_info.test_bb = test_bb;
>    if_info.then_bb = then_bb;
>    if_info.else_bb = else_bb;
> --
> 2.50.1 (Apple Git-155)
>

Reply via email to