https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127107
Bug ID: 127107
Summary: [17 Regression] long-multiple recogniser should not
apply when widening_mul is not run
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Keywords: ice-on-valid-code
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: ktkachov at gcc dot gnu.org
CC: konstantinos.eleftheriou at vrull dot eu
Target Milestone: ---
Somewhat artificial, but:
typedef __uint128_t u128;
u128
mulh (u128 x, u128 y)
{
u128 x_hi = x >> 64;
u128 x_lo = x & (u128) 0xFFFFFFFFFFFFFFFF;
u128 y_hi = y >> 64;
u128 y_lo = y & (u128) 0xFFFFFFFFFFFFFFFF;
u128 mulhilo = x_hi * y_lo;
u128 mullohi = x_lo * y_hi;
u128 cross_sum = mulhilo + mullohi;
u128 mullolo = x_lo * y_lo;
u128 shrlolo = mullolo >> 64;
u128 add_cross_sum = cross_sum + shrlolo;
int carry = add_cross_sum < mulhilo;
u128 cond = ((u128) carry << 64) + x_hi * y_hi;
return cond + (add_cross_sum >> 64);
}
on aarch64 with -O3 -fdisable-tree-widening_mul=mulh ICEs:
123
ARM64 GCC trunk - cached
Output of ARM64 GCC trunk (Compiler #1)
cc1: note: disable pass tree-widening_mul for function mulh
during RTL pass: expand
<source>: In function 'mulh':
<source>:18:15: internal compiler error: in expand_mult, at expmed.cc:3686
18 | return cond + (add_cross_sum >> 64);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
We should not be forming the initial wide multiply if the tree-widening_mul
pass does not run later on.