GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gcc/h8300

Fix instruction length calculation and output templates for H8 port

Correct H8 port's instruction length calculations and output templates to prevent branch miscalculations and assembler errors.

The H8 port incorrectly calculated instruction lengths, leading to mispredicted branches and potential assembler issues. Specifically, the length of the xor.l instruction was not fully accounted for in some cases, and certain SImode sequences required additional instructions or longer xor.l forms. This commit corrects these calculations and also fixes incorrect output templates and missing ‘%’ characters, resolving a PR and preventing regressions.

In Details

The H8 target's config/h8300/testcompare.md contained errors in instruction length calculations for several store_z patterns, particularly impacting SI modes and the xor.l instruction. This led to incorrect branch target calculations. Additionally, some output templates used incorrect modifiers and were missing essential assembler directives, potentially causing fatal assembler errors. This patch rectifies these issues and includes LLM-generated test cases.

For Context
insn
Abbreviation for instruction.
SI mode
A machine mode in GCC representing a single integer, typically 32 bits.
LLM
Large Language Model, an AI used here to scan code for potential issues and generate test cases.
Filed Under: h8300codegenbugfix