static bool
avl_can_be_propagated_p (rtx_insn *rinsn)
{
- /* The index of "vrgather dest, source, index" may pick up the
- element which has index >= AVL, so we can't strip the elements
- that has index >= AVL of source register. */
- return get_attr_type (rinsn) != TYPE_VGATHER;
+ /* We can't do AVL propagation when the instruction is potentially
+ touching the element with i > AVL. So, we don't do AVL propagation
+ on these following situations:
+
+ - The index of "vrgather dest, source, index" may pick up the
+ element which has index >= AVL, so we can't strip the elements
+ that has index >= AVL of source register.
+ - The last element of vslide1down is AVL + 1 according to RVV ISA:
+ vstart <= i < vl-1 vd[i] = vs2[i+1] if v0.mask[i] enabled
+ - The last multiple elements of vslidedown can be the element
+ has index >= AVL according to RVV ISA:
+ 0 <= i+OFFSET < VLMAX src[i] = vs2[i+OFFSET]
+ vstart <= i < vl vd[i] = src[i] if v0.mask[i] enabled. */
+ return get_attr_type (rinsn) != TYPE_VGATHER
+ && get_attr_type (rinsn) != TYPE_VSLIDEDOWN
+ && get_attr_type (rinsn) != TYPE_VISLIDE1DOWN
+ && get_attr_type (rinsn) != TYPE_VFSLIDE1DOWN;
}
static bool
vlmax_ta_p (rtx_insn *rinsn)
{
- return vlmax_avl_type_p (rinsn) && tail_agnostic_p (rinsn)
- && avl_can_be_propagated_p (rinsn);
+ return vlmax_avl_type_p (rinsn) && tail_agnostic_p (rinsn);
}
static machine_mode
rtx
pass_avlprop::get_vlmax_ta_preferred_avl (insn_info *insn) const
{
+ if (!avl_can_be_propagated_p (insn->rtl ()))
+ return NULL_RTX;
int sew = get_sew (insn->rtl ());
enum vlmul_type vlmul = get_vlmul (insn->rtl ());
int ratio = calculate_ratio (sew, vlmul);
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcv_zvfh_zfh_zvl1024b -mabi=lp64d -O3 --param=riscv-autovec-preference=fixed-vlmax" } */
+
+#include "riscv_vector.h"
+
+typedef int64_t v1024b __attribute__ ((vector_size (128)));
+
+void foo (void *out, void *in, int64_t a, int64_t b, int64_t c, int64_t d, int64_t e)
+{
+ v1024b v = {a,a,a,a,a,a,a,a,a,a,a,a,b,c,d,e};
+ __riscv_vse64_v_i64m1 (out, (vint64m1_t)v, 12);
+}
+
+/* { dg-final { scan-assembler {vsetivli\s+zero,\s*16} } } */