[Andrew: cc:ing you in case this affects/helps GCN.]

The vcond code requires the compared vectors and the selected
vectors to have both the same size and the same number of elements
as each other.  But the operation makes logical sense even for
different vector sizes.  E.g. you could compare two V4SIs and
use the result to select between two V4DIs.

The underlying optab already allows the compared mode and the selected
mode to be specified separately.  Since the vectoriser now also
supports mixed vector sizes, I think we can simply remove the
equal-size check and just keep the equal-lanes check.  It's then
up to the target to decide which (if any) mixtures of sizes it
supports.

Tested on aarch64-linux-gnu and x86_64-linux-gnu.  OK to install?

Richard


gcc/
        * optabs-tree.c (expand_vec_cond_expr_p): Allow the compared values
        and the selected values to have different mode sizes.
        * gimple-isel.cc (gimple_expand_vec_cond_expr): Likewise.
---
 gcc/gimple-isel.cc | 5 ++---
 gcc/optabs-tree.c  | 3 +--
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/gcc/gimple-isel.cc b/gcc/gimple-isel.cc
index 9186ff55cdd..b5362cc4b01 100644
--- a/gcc/gimple-isel.cc
+++ b/gcc/gimple-isel.cc
@@ -199,9 +199,8 @@ gimple_expand_vec_cond_expr (gimple_stmt_iterator *gsi,
   unsignedp = TYPE_UNSIGNED (TREE_TYPE (op0a));
 
 
-  gcc_assert (known_eq (GET_MODE_SIZE (mode), GET_MODE_SIZE (cmp_op_mode))
-             && known_eq (GET_MODE_NUNITS (mode),
-                          GET_MODE_NUNITS (cmp_op_mode)));
+  gcc_assert (known_eq (GET_MODE_NUNITS (mode),
+                       GET_MODE_NUNITS (cmp_op_mode)));
 
   icode = get_vcond_icode (mode, cmp_op_mode, unsignedp);
   if (icode == CODE_FOR_nothing)
diff --git a/gcc/optabs-tree.c b/gcc/optabs-tree.c
index badd30bfda8..4dfda756932 100644
--- a/gcc/optabs-tree.c
+++ b/gcc/optabs-tree.c
@@ -377,8 +377,7 @@ expand_vec_cond_expr_p (tree value_type, tree cmp_op_type, 
enum tree_code code)
                               TYPE_MODE (cmp_op_type)) != CODE_FOR_nothing)
     return true;
 
-  if (maybe_ne (GET_MODE_SIZE (value_mode), GET_MODE_SIZE (cmp_op_mode))
-      || maybe_ne (GET_MODE_NUNITS (value_mode), GET_MODE_NUNITS 
(cmp_op_mode)))
+  if (maybe_ne (GET_MODE_NUNITS (value_mode), GET_MODE_NUNITS (cmp_op_mode)))
     return false;
 
   if (TREE_CODE_CLASS (code) != tcc_comparison)
-- 
2.17.1

Reply via email to