https://gcc.gnu.org/g:21455788f0f89ea547acb0f6f5318642a82d9f53
commit r17-6338-g21455788f0f89ea547acb0f6f5318642a82d9f53 Author: Jakub Jelinek <[email protected]> Date: Tue Nov 17 09:36:43 2026 +0100 internal-fn: Fix ICE during IFN_CLMUL expansion [PR128578] These two ifns are marked as ECF_CONST, so normally if their lhs is unused, they are DCEd. But at -O0 or when trying hard with disabling passes it can happen that the lhs is NULL_TREE and the stmt hasn't been optimized out. Similarly to other ECF_CONST ifn expansions, this patch does nothing for those cases instead of trying to expand_expr the NULL_TREE and ICEing on it. 2026-11-17 Jakub Jelinek <[email protected]> PR middle-end/128578 * internal-fn.cc (expand_CLMUL, expand_CLMUL_WIDEN): If lhs is NULL_TREE, don't do anything. * gcc.dg/builtin-clmulg-1.c: New test. Reviewed-by: Andrea Pinski <[email protected]> Diff: --- gcc/internal-fn.cc | 4 ++++ gcc/testsuite/gcc.dg/builtin-clmulg-1.c | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/gcc/internal-fn.cc b/gcc/internal-fn.cc index d277a07eaf7f..bf635c45a408 100644 --- a/gcc/internal-fn.cc +++ b/gcc/internal-fn.cc @@ -6323,6 +6323,8 @@ void expand_CLMUL (internal_fn, gcall *stmt) { tree lhs = gimple_call_lhs (stmt); + if (lhs == NULL_TREE) + return; tree arg0 = gimple_call_arg (stmt, 0); tree arg1 = gimple_call_arg (stmt, 1); scalar_int_mode mode = SCALAR_INT_TYPE_MODE (TREE_TYPE (arg0)); @@ -6347,6 +6349,8 @@ void expand_CLMUL_WIDEN (internal_fn, gcall *stmt) { tree lhs = gimple_call_lhs (stmt); + if (lhs == NULL_TREE) + return; tree arg0 = gimple_call_arg (stmt, 0); tree arg1 = gimple_call_arg (stmt, 1); scalar_int_mode mode = SCALAR_INT_TYPE_MODE (TREE_TYPE (arg0)); diff --git a/gcc/testsuite/gcc.dg/builtin-clmulg-1.c b/gcc/testsuite/gcc.dg/builtin-clmulg-1.c new file mode 100644 index 000000000000..37ab40768c8a --- /dev/null +++ b/gcc/testsuite/gcc.dg/builtin-clmulg-1.c @@ -0,0 +1,9 @@ +/* PR middle-end/128578 */ +/* { dg-do compile } */ +/* { dg-options "-O0" } */ + +void +foo (unsigned int x, unsigned int y) +{ + __builtin_clmulg (x, y); +}
