public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [gimple-isel] Remove redundant if condition
@ 2021-10-05  7:10 Prathamesh Kulkarni
  2021-10-05 11:32 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Prathamesh Kulkarni @ 2021-10-05  7:10 UTC (permalink / raw)
  To: gcc Patches

[-- Attachment #1: Type: text/plain, Size: 1490 bytes --]

Hi,
In gimple_expand_vec_cond_expr:

  icode = get_vcond_icode (mode, cmp_op_mode, unsignedp);
  if (icode == CODE_FOR_nothing)
    {
      if (tcode == LT_EXPR
          && op0a == op0)
        {
          /* A VEC_COND_EXPR condition could be folded from EQ_EXPR/NE_EXPR
             into a constant when only get_vcond_eq_icode is supported.
             Try changing it to NE_EXPR.  */
          tcode = NE_EXPR;
        }
      if ((tcode == EQ_EXPR || tcode == NE_EXPR)
          && direct_internal_fn_supported_p (IFN_VCONDEQ, TREE_TYPE (lhs),
                                             TREE_TYPE (op0a),
                                             OPTIMIZE_FOR_BOTH))
        {
          tree tcode_tree = build_int_cst (integer_type_node, tcode);
          return gimple_build_call_internal (IFN_VCONDEQ, 5, op0a, op0b, op1,
                                             op2, tcode_tree);
        }
    }

  if (icode == CODE_FOR_nothing)
    {
      gcc_assert (VECTOR_BOOLEAN_TYPE_P (TREE_TYPE (op0))
                  && can_compute_op0
                  && (get_vcond_mask_icode (mode, TYPE_MODE (TREE_TYPE (op0)))
                      != CODE_FOR_nothing));
      return gimple_build_call_internal (IFN_VCOND_MASK, 3, op0, op1, op2);
    }

It seems the second check for icode == COND_FOR_nothing is redundant,
since icode is not reassigned in the previous block ?
The attached patch removes the second if condition.
OK to commit after bootstrap+test ?

Thanks,
Prathamesh

[-- Attachment #2: foo.diff --]
[-- Type: application/octet-stream, Size: 522 bytes --]

diff --git a/gcc/gimple-isel.cc b/gcc/gimple-isel.cc
index 2c78a08d3f1..38e90933c3e 100644
--- a/gcc/gimple-isel.cc
+++ b/gcc/gimple-isel.cc
@@ -260,10 +260,7 @@ gimple_expand_vec_cond_expr (gimple_stmt_iterator *gsi,
 	  return gimple_build_call_internal (IFN_VCONDEQ, 5, op0a, op0b, op1,
 					     op2, tcode_tree);
 	}
-    }
 
-  if (icode == CODE_FOR_nothing)
-    {
       gcc_assert (VECTOR_BOOLEAN_TYPE_P (TREE_TYPE (op0))
 		  && can_compute_op0
 		  && (get_vcond_mask_icode (mode, TYPE_MODE (TREE_TYPE (op0)))

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [gimple-isel] Remove redundant if condition
  2021-10-05  7:10 [gimple-isel] Remove redundant if condition Prathamesh Kulkarni
@ 2021-10-05 11:32 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2021-10-05 11:32 UTC (permalink / raw)
  To: Prathamesh Kulkarni; +Cc: gcc Patches

On Tue, Oct 5, 2021 at 9:11 AM Prathamesh Kulkarni via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> Hi,
> In gimple_expand_vec_cond_expr:
>
>   icode = get_vcond_icode (mode, cmp_op_mode, unsignedp);
>   if (icode == CODE_FOR_nothing)
>     {
>       if (tcode == LT_EXPR
>           && op0a == op0)
>         {
>           /* A VEC_COND_EXPR condition could be folded from EQ_EXPR/NE_EXPR
>              into a constant when only get_vcond_eq_icode is supported.
>              Try changing it to NE_EXPR.  */
>           tcode = NE_EXPR;
>         }
>       if ((tcode == EQ_EXPR || tcode == NE_EXPR)
>           && direct_internal_fn_supported_p (IFN_VCONDEQ, TREE_TYPE (lhs),
>                                              TREE_TYPE (op0a),
>                                              OPTIMIZE_FOR_BOTH))
>         {
>           tree tcode_tree = build_int_cst (integer_type_node, tcode);
>           return gimple_build_call_internal (IFN_VCONDEQ, 5, op0a, op0b, op1,
>                                              op2, tcode_tree);
>         }
>     }
>
>   if (icode == CODE_FOR_nothing)
>     {
>       gcc_assert (VECTOR_BOOLEAN_TYPE_P (TREE_TYPE (op0))
>                   && can_compute_op0
>                   && (get_vcond_mask_icode (mode, TYPE_MODE (TREE_TYPE (op0)))
>                       != CODE_FOR_nothing));
>       return gimple_build_call_internal (IFN_VCOND_MASK, 3, op0, op1, op2);
>     }
>
> It seems the second check for icode == COND_FOR_nothing is redundant,
> since icode is not reassigned in the previous block ?
> The attached patch removes the second if condition.
> OK to commit after bootstrap+test ?
>
OK.

> Thanks,
> Prathamesh

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-10-05 11:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-05  7:10 [gimple-isel] Remove redundant if condition Prathamesh Kulkarni
2021-10-05 11:32 ` Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).