Skip to content

Add saturating add/sub intrinsics to RISC-V vector backend#9185

Open
rajeshgangam wants to merge 1 commit into
halide:mainfrom
rajeshgangam:riscv-saturating-ops
Open

Add saturating add/sub intrinsics to RISC-V vector backend#9185
rajeshgangam wants to merge 1 commit into
halide:mainfrom
rajeshgangam:riscv-saturating-ops

Conversation

@rajeshgangam

Copy link
Copy Markdown

Summary

  • Map saturating_add to RVV vsadd.vv / vsaddu.vv instructions
  • Map saturating_sub to RVV vssub.vv / vssubu.vv instructions
  • Add corresponding simd_op_check_riscv test cases

These are the most commonly used missing operations for image processing workloads (clamped arithmetic). They fit the existing RISCVIntrinsic table pattern with zero infrastructure changes — just 4 new table entries per signedness.

Fixes #9184

Test plan

  • simd_op_check_riscv checks for vsadd.vv, vsaddu.vv, vssub.vv, vssubu.vv instruction patterns in generated assembly
  • Existing halving_add, rounding_halving_add, widening_* tests continue to pass
  • CI passes

Co-authored-by: Claude Opus 4.6 noreply@anthropic.com

Map Halide's saturating_add and saturating_sub operations to
RVV instructions vsadd/vsaddu and vssub/vssubu respectively.
These are commonly used in image processing for clamped arithmetic
and were missing from the RISC-V intrinsic tables.

Fixes halide#9184
@rajeshgangam rajeshgangam force-pushed the riscv-saturating-ops branch from 4458ff3 to d156545 Compare June 24, 2026 15:54
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.

Expand RISC-V vector backend with missing intrinsics

1 participant