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

widen_mul: Avoids infinite loop in match_uaddc_usubc for PR129090

Fixes an infinite loop in widen_mul's overflow check by correctly handling identical overflow calls.

A bug in the match_uaddc_usubc function within the widen_mul optimization pass could lead to an infinite loop. This occurred when the function incorrectly assumed two distinct overflow calls (.ADD_OVERFLOW or .SUB_OVERFLOW) were present, even if they were identical. The fix modifies the function to reject cases where the two overflow call trees (ovf1 and ovf2) are the same, preventing the loop and ensuring correct handling of unsigned addition/subtraction with overflow detection.

In Details

The match_uaddc_usubc function in tree-ssa-math-opts.cc has a loop intended to find two distinct overflow calls (ovf1, ovf2) chained via IMAGPART_EXPR. The original code assumes ovf1 != ovf2 and iterates, but if ovf1 == ovf2, it loops infinitely without a break. This patch adds a check to punt if ovf1 == ovf2 at the outset, resolving PR129090.

For Context
widen_mul
A GCC optimization pass that handles multiplication operations that result in a wider data type, often used for arbitrary-precision arithmetic or certain low-level operations.
match_uaddc_usubc
A specific function within GCC's tree optimization passes that attempts to match patterns for unsigned addition/subtraction with carry/overflow.
GIMPLE
GCC's internal, higher-level intermediate representation, used after initial parsing and before RTL generation.
PR129090
Problem Report 129090, a bug filed against GCC indicating an issue with the widen_mul optimization.
Filed Under: optimizationwiden_mulbugfix