[Bug tree-optimization/123372] [15 Regression] ICE in expand_fn_using_insn on .SAT_SUB while building OpenTTD with LTO since r15-1671
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Jan 16 23:51:07 GMT 2026
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123372
--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-15 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:5d343a467ba03606ff3f4c27b7b49b2b79015593
commit r15-10690-g5d343a467ba03606ff3f4c27b7b49b2b79015593
Author: Jakub Jelinek <jakub@redhat.com>
Date: Sat Jan 3 14:27:41 2026 +0100
widening_mul: Fix up .SAT_{ADD,SUB,MUL} pattern recognition [PR123372]
The following testcase ICEs since r15-1671, because the match.pd pattern
now allows a cast and the function checks whether the ifn is supported
on a wrong type. .SAT_{ADD,SUB,MUL} are binary ifns, so they care about
the type of their first operand:
#define binary_direct { 0, 0, true }
where
/* optabs can be parameterized by one or two modes. These fields
describe
how to select those modes from the types of the return value and
arguments. A value of -1 says that the mode is determined by the
return type while a value N >= 0 says that the mode is determined by
the type of argument N. A value of -2 says that this internal
function isn't directly mapped to an optab. */
but in this function (unlike the function right below it for the
same ifns) checks the type of the lhs which since that change can be
actually a different type (expansion performs the operation on the
argument types and then casts the result to the lhs type).
So, e.g. on x86_64 -m32, it checks wether ussubsi3 insn can be used
(which it can), but then actually uses it on DImode arguments and
ussubdi3 is TARGET_64BIT only. Similarly for -m64 it checks ussubsi3 too
instead of ussubti3 (which doesn't exist).
2026-01-03 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/123372
* tree-ssa-math-opts.cc
(build_saturation_binary_arith_call_and_replace): Pass type of op_0
rather than type of lhs as second argument to
direct_internal_fn_supported_p.
* gcc.dg/tree-ssa/pr123372.c: New test.
(cherry picked from commit c7206efa282bdd121ae4bd5227b487d06c3874c2)
More information about the Gcc-bugs
mailing list