GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
hppa

hppa: Fix hppa_rtx_costs_shadd_p to handle subregs in inner operands

Fixes the HPPA backend to correctly handle subregister operands in cost calculations for the 'shadd' instruction.

The HPPA backend’s cost calculation for the shadd instruction has been fixed to properly handle subregister operands. Previously, hppa_rtx_costs_shadd_p did not correctly strip SUBREG wrappers from inner operands, leading to incorrect cost estimations and issues with certain patterns on specific HPPA configurations.

In Details

The hppa_rtx_costs_shadd_p function, responsible for calculating the RTX costs of the shadd instruction pattern on HPPA targets, failed to properly canonicalize inner operands when they were subregs. This commit modifies the function to strip SUBREG wrappers from these inner operands before checking the pattern, resolving a bug in gcc.target/hppa/shadd-4.c on hppa64-hp-hpux11.11.

For Context
HPPA
Hewlett-Packard Precision Architecture. A family of RISC instruction set architectures developed by Hewlett-Packard.
RTX
Representation of intermediate language used by GCC. It's a set of C data structures representing abstract machine instructions and operands.
subreg
A subregister is a portion of a larger hardware register. In GCC's RTX representation, SUBREG is an operator that denotes accessing a part of a register.
shadd
A specific instruction, likely performing a shifted addition, relevant to the HPPA architecture.
Filed Under: hppabugfix