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

amdgcn: Fix 64-bit multiply edge cases with negative immediate constants

Corrects 64-bit multiplication for negative immediate constants on AMD GCN targets.

This commit addresses issues with 64-bit multiplications involving negative immediate constants on AMD GCN targets. The problem arises from the 32-bit encoding used in the assembler. The fix involves forcing such constants into a register before the multiplication, ensuring correct handling across different modes.

In Details

The mulsi3_highpart and mulsidi3 patterns in gcn.md are being updated to handle DImode multiplication of negative immediate constants. Previously, this could lead to incorrect results due to the 32-bit immediate encoding. The fix restricts the use of _imm insns to constants that are representable identically in both SImode and DImode, and for other cases, it forces the operand into a register. A specific adjustment is also made for muldi3 to load negative low-part constants.

For Context
DImode
GCC's internal representation mode for signed 64-bit integers.
SImode
GCC's internal representation mode for signed 32-bit integers.
insn
An instruction in the target machine's assembly language, as represented in GCC's intermediate representation.
amdgcn
The target architecture for AMD's Graphics Core Next GPUs, targeted by GCC.
Filed Under: amd gcncompilerfixassembly