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
@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@2fad88f). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #9185   +/-   ##
=======================================
  Coverage        ?   69.38%           
=======================================
  Files           ?      254           
  Lines           ?    78274           
  Branches        ?    18729           
=======================================
  Hits            ?    54309           
  Misses          ?    18483           
  Partials        ?     5482           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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