From: Alex Coplan Date: Fri, 5 Jun 2026 15:51:47 +0000 (+0100) Subject: expmed: Fix up CONST_POLY_INT case of make_tree [PR125621] X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=06193eabd2b787bd3815d99b08b1c8b18ca800ea;p=thirdparty%2Fgcc.git expmed: Fix up CONST_POLY_INT case of make_tree [PR125621] The PR showed us ICEing in build_poly_int_cst because we have type set to a non-type tree node (a var_decl). A closer look shows this is because we pass the wrong variable to wide_int_to_tree in expmed.cc:make_tree: we pass t instead of type, where t is uninitialized at the point of the call. Fixed thusly. I also took the opportunity to move the CONST_POLY_INT case out of the default: section into its own case of the switch. gcc/ChangeLog: PR middle-end/125621 * expmed.cc (make_tree): Fix CONST_POLY_INT case to pass type instead of t, move it to its own switch case. gcc/testsuite/ChangeLog: PR middle-end/125621 * gcc.target/aarch64/torture/pr125621.c: New test. --- diff --git a/gcc/expmed.cc b/gcc/expmed.cc index 3e8a6affde7..e4433384c59 100644 --- a/gcc/expmed.cc +++ b/gcc/expmed.cc @@ -5417,6 +5417,9 @@ make_tree (tree type, rtx x) t = wide_int_to_tree (type, rtx_mode_t (x, TYPE_MODE (type))); return t; + case CONST_POLY_INT: + return wide_int_to_tree (type, const_poly_int_value (x)); + case CONST_DOUBLE: STATIC_ASSERT (HOST_BITS_PER_WIDE_INT * 2 <= MAX_BITSIZE_MODE_ANY_INT); if (TARGET_SUPPORTS_WIDE_INT == 0 && GET_MODE (x) == VOIDmode) @@ -5508,9 +5511,6 @@ make_tree (tree type, rtx x) /* fall through. */ default: - if (CONST_POLY_INT_P (x)) - return wide_int_to_tree (t, const_poly_int_value (x)); - t = build_decl (RTL_LOCATION (x), VAR_DECL, NULL_TREE, type); /* If TYPE is a POINTER_TYPE, we might need to convert X from diff --git a/gcc/testsuite/gcc.target/aarch64/torture/pr125621.c b/gcc/testsuite/gcc.target/aarch64/torture/pr125621.c new file mode 100644 index 00000000000..32f18d210c6 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/torture/pr125621.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-march=armv8.2-a+sve -fsanitize=undefined" } */ +#include + +long foo(long x) { + return (long)svcntd() * x; +}