Skip to content

RISC-V: Do not use vsetivli for THeadVector.#9

Open
pz9115 wants to merge 1 commit into
revyos:revyos-gcc14.3from
pz9115:patch-1
Open

RISC-V: Do not use vsetivli for THeadVector.#9
pz9115 wants to merge 1 commit into
revyos:revyos-gcc14.3from
pz9115:patch-1

Conversation

@pz9115

@pz9115 pz9115 commented May 14, 2026

Copy link
Copy Markdown

in emit_vlmax_insn_lra we use a vsetivli for an immediate AVL. XTHeadVector does not support this, so guard appropriately.

Regtested on rv64gcv_zvl512b.

Regards
Robin

PR target/120461

gcc/ChangeLog:

* config/riscv/riscv-v.cc (emit_vlmax_insn_lra): Do not emit vsetivli for XTHeadVector.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/xtheadvector/pr120461.c: New test.

Thanks for taking the time to contribute to GCC! Please be advised that if you are
viewing this on github.com, that the mirror there is unofficial and unmonitored.
The GCC community does not use github.com for their contributions. Instead, we use
a mailing list (gcc-patches@gcc.gnu.org) for code submissions, code reviews, and
bug reports. Please send patches there instead.

Summary by Sourcery

Guard use of immediate-AVL vsetivli in RISC-V VL-max emission so it is not used for XTHeadVector targets and add a regression test for the reported issue.

Bug Fixes:

  • Avoid emitting vsetivli with immediate AVL for XTHeadVector RISC-V targets, which do not support this instruction form.

Tests:

  • Add a RISC-V RVV XTHeadVector test to verify compilation with immediate AVL handling and zeroing of call-used registers.

Hi,

in emit_vlmax_insn_lra we use a vsetivli for an immediate AVL.
XTHeadVector does not support this, so guard appropriately.

Regtested on rv64gcv_zvl512b.

Regards
 Robin

	PR target/120461

gcc/ChangeLog:

	* config/riscv/riscv-v.cc (emit_vlmax_insn_lra): Do not emit
	vsetivli for XTHeadVector.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/xtheadvector/pr120461.c: New test.
@sourcery-ai

sourcery-ai Bot commented May 14, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR updates the RISC-V vector code generator to avoid emitting vsetivli for XTHeadVector targets when computing VLMAX in post-RA, and adds a regression test to ensure compilation succeeds for xt-c920 with specific RVV and register-zeroing options.

Flow diagram for emit_vlmax_insn_lra vsetivli emission guard

flowchart TD
  A[emit_vlmax_insn_lra] --> B["Check imm_avl_p(mode)"]
  B -->|false| E[Skip vsetivli emission]
  B -->|true| C[Check TARGET_XTHEADVECTOR]
  C -->|true| E
  C -->|false| D[Emit vsetivli for immediate AVL]
  D --> F[Continue with VLMAX handling]
  E --> F
Loading

File-Level Changes

Change Details Files
Guard immediate-AVL vsetivli emission in emit_vlmax_insn_lra so it is skipped for XTHeadVector targets.
  • Tighten the condition that checks for immediate AVL so it additionally verifies that XTHeadVector is not the active target.
  • Preserve existing post-RA optimization comment and behavior for non-XTHeadVector targets while avoiding generation of unsupported vsetivli instructions on XTHeadVector.
gcc/config/riscv/riscv-v.cc
Add a regression test for PR target/120461 to validate code generation for XTHeadVector with RVV and zero-call-used-regs options.
  • Introduce a new RISC-V RVV xtheadvector test that compiles an empty function with -mcpu=xt-c920, -mrvv-vector-bits=zvl, and -fzero-call-used-regs=all.
  • Use dg-do compile and dg-options directives to ensure the test focuses on successful compilation rather than runtime behavior.
gcc/testsuite/gcc.target/riscv/rvv/xtheadvector/pr120461.c

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant