I think it's better to make it "demand policy" for "agnostic" instead of changing the fusion rule.
Could you try this ? In riscv-vsetvl.cc line: 1147 - 1150 if (!m_ta) dflags |= demand_flags::DEMAND_TAIL_POLICY_P; if (!m_ma) dflags |= demand_flags::DEMAND_MASK_POLICY_P; change it to: if (!m_ta || riscv_prefer_agnostic_p ()) dflags |= demand_flags::DEMAND_TAIL_POLICY_P; if (!m_ma || riscv_prefer_agnostic_p ()) dflags |= demand_flags::DEMAND_MASK_POLICY_P; to see whether it can work ? [email protected] From: Zhongyao Chen Date: 2025-09-26 15:17 To: 钟居哲 Subject: Re: Re: [PATCH] RISC-V: Add 'prefer_agnostic' tune parameter for vector policies On Fri, Sep 26, 2025 at 2:53 PM 钟居哲 <[email protected]> wrote: > > I understand what you want. > But my question is why this following changes don't satisfy your need and why > you need to change VSETVL PASS: > > >> - /* TODO: By default, we choose to use TAIL_ANY which allows > >> - compiler pick up either agnostic or undisturbed. Maybe we > >> - will have a compile option like -mprefer=agnostic to set > >> - this value???. */ > >> + if (riscv_prefer_agnostic_p ()) > >> + return TAIL_AGNOSTIC; > > > >> - /* TODO: By default, we choose to use MASK_ANY which allows > >> - compiler pick up either agnostic or undisturbed. Maybe we > >> - will have a compile option like -mprefer=agnostic to set > >> - this value???. */ > >>+ if (riscv_prefer_agnostic_p ()) > >> + return MASK_AGNOSTIC; > >> return MASK_ANY; > > > The VSETVL PASS should be able to disable fusion if you explicit set it as > "agnostic". > > ________________________________ > [email protected] testing shows that these changes alone do not prevent fusion. I believe the issue lies in the policy rules: DEF_POLICY_RULE (tail_policy_only, ignore_policy, tail_policy_only, always_true, always_true, nop) DEF_POLICY_RULE (ignore_policy, tail_policy_only, tail_policy_only, always_true, always_false, use_tail_policy) The always_true condition in these rules indicates that fusion is always allowed.
