Landing: a8072f31bc90

Project / Subsystem

gcc / tree-optimization

Date

2026-07-03

Author

Naveen

Commit

a8072f31bc90000b3b8a2c0c7819710cf924727a

Source

github

Perf win

Yes

Breaking

No

All attributes

project
gcc
subsystem
tree-optimization
patch_id
commit_hash
a8072f31bc90000b3b8a2c0c7819710cf924727a
source_type
github
headline
tree-optimization: fold memset with length in [0, 1] to conditional store [PR102202]
tldr
Optimizes small `memset` calls to simple conditional stores.
author
Naveen
outcome
committed
performance_win
true
breaking_change
false
series_id
series_parts
[]
tags
  • optimization
  • memset
  • simplification
discussion_id_link
bugzilla_pr
date
2026-07-03T00:00:00.000Z

The compiler now optimizes memset calls with lengths of 0 or 1 more effectively. For a zero-length memset, the call is shrink-wrapped. For a one-length memset, it’s replaced with a direct byte store. This optimization leverages Ranger analysis to identify these cases, even when the length is determined by runtime values within a provable range, not just constants. This improves performance by eliminating function call overhead and simplifying the generated code.