]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
RISC-V: Allow non-duplicate bool patterns in expand_const_vector
authorPatrick O'Neill <patrick@rivosinc.com>
Tue, 20 Aug 2024 19:50:51 +0000 (12:50 -0700)
committerPatrick O'Neill <patrick@rivosinc.com>
Tue, 27 Aug 2024 17:05:42 +0000 (10:05 -0700)
Currently we assert when encountering a non-duplicate boolean vector.
This patch allows non-duplicate vectors to fall through to the
gcc_unreachable and assert there.

This will be useful when adding a catch-all pattern to emit costs and
handle arbitary vectors.

gcc/ChangeLog:

* config/riscv/riscv-v.cc (expand_const_vector): Allow non-duplicate
to fall through other patterns before asserting.

Signed-off-by: Patrick O'Neill <patrick@rivosinc.com>
gcc/config/riscv/riscv-v.cc

index 32349677dc285cbc54beaf1c3ba3c156f4b692de..cb2380ad66437e3f5db4946ed301c9c288e55952 100644 (file)
@@ -1109,26 +1109,19 @@ expand_const_vector (rtx target, rtx src)
 {
   machine_mode mode = GET_MODE (target);
   rtx result = register_operand (target, mode) ? target : gen_reg_rtx (mode);
-  if (GET_MODE_CLASS (mode) == MODE_VECTOR_BOOL)
-    {
-      rtx elt;
-      gcc_assert (
-       const_vec_duplicate_p (src, &elt)
-       && (rtx_equal_p (elt, const0_rtx) || rtx_equal_p (elt, const1_rtx)));
-      rtx ops[] = {result, src};
-      emit_vlmax_insn (code_for_pred_mov (mode), UNARY_MASK_OP, ops);
-
-      if (result != target)
-       emit_move_insn (target, result);
-      return;
-    }
-
   rtx elt;
   if (const_vec_duplicate_p (src, &elt))
     {
+      if (GET_MODE_CLASS (mode) == MODE_VECTOR_BOOL)
+       {
+         gcc_assert (rtx_equal_p (elt, const0_rtx)
+                     || rtx_equal_p (elt, const1_rtx));
+         rtx ops[] = {result, src};
+         emit_vlmax_insn (code_for_pred_mov (mode), UNARY_MASK_OP, ops);
+       }
       /* Element in range -16 ~ 15 integer or 0.0 floating-point,
         we use vmv.v.i instruction.  */
-      if (valid_vec_immediate_p (src))
+      else if (valid_vec_immediate_p (src))
        {
          rtx ops[] = {result, src};
          emit_vlmax_insn (code_for_pred_mov (mode), UNARY_OP, ops);