Landing: 141edd02af70

Project / Subsystem

gcc / gcc/fold-const

Date

2026-08-05

Author

Jakub Jelinek

Commit

141edd02af705696f89ff9a804879dc51834898d

Source

github

Perf win

No

Breaking

No

All attributes

project
gcc
subsystem
gcc/fold-const
patch_id
—
commit_hash
141edd02af705696f89ff9a804879dc51834898d
source_type
github
headline
Improve pointer arithmetic optimizations in fold-const and match.pd.
tldr
Enhances optimization of pointer differences involving casts and address expressions.
author
Jakub Jelinek
outcome
committed
performance_win
false
breaking_change
false
series_id
—
series_parts
[]
tags
  • • optimization
  • • compiler
  • • C++
discussion_id_link
—
bugzilla_pr
—
date
2026-08-05T00:00:00.000Z

Optimizations for constant pointer differences have been improved by refining the ptr_difference_const logic in match.pd and fold-const.cc. The changes address issues where certain pointer arithmetic expressions, particularly those involving casts and address expressions, were not handled correctly. By adding checks for no-operation conversions and ADDR_EXPR requirements, the compiler can now more reliably fold these expressions, preventing potential regressions and ICEs (Internal Compiler Errors).