Landing: bed251d3acf3

Project / Subsystem

gcc / gcc

Date

2026-06-04

Author

Raphael Zinsly

Commit

bed251d3acf34ecdb27eed40fbc4a672a299e1de

Source

github

Perf win

Yes

Breaking

No

All attributes

project
gcc
subsystem
gcc
patch_id
commit_hash
bed251d3acf34ecdb27eed40fbc4a672a299e1de
source_type
github
headline
GCC correctly costs `mulh` instruction for RISC-V, improving code generation.
tldr
GCC now properly costs the RISC-V `mulh` instruction, leading to better code generation by favoring multiplication for division-by-constant.
author
Raphael Zinsly
outcome
committed
performance_win
true
breaking_change
false
series_id
series_parts
[]
tags
  • risc-v
  • optimization
  • code-generation
  • cost-model
discussion_id_link
bugzilla_pr
date
2026-06-04T00:00:00.000Z

This commit fixes an issue where the RISC-V mulh instruction was incorrectly costed, causing GCC to generate suboptimal code. The previous miscalculation made multiplication-by-reciprocal for division-by-constant operations appear too expensive, discouraging its use. By correctly recognizing the mulh RTL and using appropriate integer multiply costs, GCC can now make more efficient code generation decisions, leading to performance improvements.