[gcc r17-1446] expmed: Fix up CONST_POLY_INT case of make_tree [PR125621]
Alex Coplan
acoplan@gcc.gnu.org
Tue Jun 9 12:57:58 GMT 2026
https://gcc.gnu.org/g:06193eabd2b787bd3815d99b08b1c8b18ca800ea
commit r17-1446-g06193eabd2b787bd3815d99b08b1c8b18ca800ea
Author: Alex Coplan <alex.coplan@arm.com>
Date: Fri Jun 5 16:51:47 2026 +0100
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:
---
gcc/expmed.cc | 6 +++---
gcc/testsuite/gcc.target/aarch64/torture/pr125621.c | 7 +++++++
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/gcc/expmed.cc b/gcc/expmed.cc
index 3e8a6affde7b..e4433384c591 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 000000000000..32f18d210c61
--- /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 <arm_sve.h>
+
+long foo(long x) {
+ return (long)svcntd() * x;
+}
More information about the Gcc-cvs
mailing list